
<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>pymatgen.io.gaussian &#8212; pymatgen 2020.7.3 documentation</title>
    <link rel="stylesheet" href="../../../_static/basic.css" type="text/css" />
    <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
    <script id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
    <script src="../../../_static/jquery.js"></script>
    <script src="../../../_static/underscore.js"></script>
    <script src="../../../_static/doctools.js"></script>
    <script src="../../../_static/language_data.js"></script>
    <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <link rel="index" title="Index" href="../../../genindex.html" />
    <link rel="search" title="Search" href="../../../search.html" />
 
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-33990148-1']);
  _gaq.push(['_trackPageview']);
</script>

  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../index.html">pymatgen 2020.7.3 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../../pymatgen.html" accesskey="U">pymatgen</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">pymatgen.io.gaussian</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
          <div class="body" role="main">
            
  <h1>Source code for pymatgen.io.gaussian</h1><div class="highlight"><pre>
<span></span><span class="c1"># coding: utf-8</span>
<span class="c1"># Copyright (c) Pymatgen Development Team.</span>
<span class="c1"># Distributed under the terms of the MIT License.</span>

<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">This module implements input and output processing from Gaussian.</span>
<span class="sd">&quot;&quot;&quot;</span>

<span class="kn">import</span> <span class="nn">re</span>

<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="kn">import</span> <span class="nn">warnings</span>

<span class="kn">from</span> <span class="nn">pymatgen.core.operations</span> <span class="kn">import</span> <span class="n">SymmOp</span>
<span class="kn">from</span> <span class="nn">pymatgen</span> <span class="kn">import</span> <span class="n">Element</span><span class="p">,</span> <span class="n">Molecule</span><span class="p">,</span> <span class="n">Composition</span>
<span class="kn">from</span> <span class="nn">monty.io</span> <span class="kn">import</span> <span class="n">zopen</span>
<span class="kn">from</span> <span class="nn">pymatgen.core.units</span> <span class="kn">import</span> <span class="n">Ha_to_eV</span>
<span class="kn">from</span> <span class="nn">pymatgen.util.coord</span> <span class="kn">import</span> <span class="n">get_angle</span>
<span class="kn">import</span> <span class="nn">scipy.constants</span> <span class="k">as</span> <span class="nn">cst</span>

<span class="kn">from</span> <span class="nn">pymatgen.electronic_structure.core</span> <span class="kn">import</span> <span class="n">Spin</span>

<span class="n">__author__</span> <span class="o">=</span> <span class="s1">&#39;Shyue Ping Ong, Germain  Salvato-Vallverdu, Xin Chen&#39;</span>
<span class="n">__copyright__</span> <span class="o">=</span> <span class="s1">&#39;Copyright 2013, The Materials Virtual Lab&#39;</span>
<span class="n">__version__</span> <span class="o">=</span> <span class="s1">&#39;0.1&#39;</span>
<span class="n">__maintainer__</span> <span class="o">=</span> <span class="s1">&#39;Shyue Ping Ong&#39;</span>
<span class="n">__email__</span> <span class="o">=</span> <span class="s1">&#39;ongsp@ucsd.edu&#39;</span>
<span class="n">__date__</span> <span class="o">=</span> <span class="s1">&#39;8/1/15&#39;</span>


<span class="n">float_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;\s*([+-]?\d+\.\d+)&quot;</span><span class="p">)</span>


<div class="viewcode-block" id="read_route_line"><a class="viewcode-back" href="../../../pymatgen.io.gaussian.html#pymatgen.io.gaussian.read_route_line">[docs]</a><span class="k">def</span> <span class="nf">read_route_line</span><span class="p">(</span><span class="n">route</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    read route line in gaussian input/output and return functional basis_set</span>
<span class="sd">    and a dictionary of other route parameters</span>

<span class="sd">    Args:</span>
<span class="sd">        route (str) : the route line</span>

<span class="sd">    return</span>
<span class="sd">        functional (str) : the method (HF, PBE ...)</span>
<span class="sd">        basis_set (str) : the basis set</span>
<span class="sd">        route (dict) : dictionary of parameters</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">scrf_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;^([sS][cC][rR][fF])\s*=\s*(.+)&quot;</span><span class="p">)</span>
    <span class="n">multi_params_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;^([A-z]+[0-9]*)[\s=]+\((.*)\)$&quot;</span><span class="p">)</span>
    <span class="n">functional</span> <span class="o">=</span> <span class="kc">None</span>
    <span class="n">basis_set</span> <span class="o">=</span> <span class="kc">None</span>
    <span class="n">route_params</span> <span class="o">=</span> <span class="p">{}</span>
    <span class="n">dieze_tag</span> <span class="o">=</span> <span class="kc">None</span>
    <span class="k">if</span> <span class="n">route</span><span class="p">:</span>
        <span class="k">if</span> <span class="s2">&quot;/&quot;</span> <span class="ow">in</span> <span class="n">route</span><span class="p">:</span>
            <span class="n">tok</span> <span class="o">=</span> <span class="n">route</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;/&quot;</span><span class="p">)</span>
            <span class="n">functional</span> <span class="o">=</span> <span class="n">tok</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">()[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
            <span class="n">basis_set</span> <span class="o">=</span> <span class="n">tok</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span>
            <span class="k">for</span> <span class="n">tok</span> <span class="ow">in</span> <span class="p">[</span><span class="n">functional</span><span class="p">,</span> <span class="n">basis_set</span><span class="p">,</span> <span class="s2">&quot;/&quot;</span><span class="p">]:</span>
                <span class="n">route</span> <span class="o">=</span> <span class="n">route</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">tok</span><span class="p">,</span> <span class="s2">&quot;&quot;</span><span class="p">)</span>

        <span class="k">for</span> <span class="n">tok</span> <span class="ow">in</span> <span class="n">route</span><span class="o">.</span><span class="n">split</span><span class="p">():</span>
            <span class="k">if</span> <span class="n">scrf_patt</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">tok</span><span class="p">):</span>
                <span class="n">m</span> <span class="o">=</span> <span class="n">scrf_patt</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">tok</span><span class="p">)</span>
                <span class="n">route_params</span><span class="p">[</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">)]</span> <span class="o">=</span> <span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
            <span class="k">elif</span> <span class="n">tok</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;#&quot;</span><span class="p">,</span> <span class="s2">&quot;#N&quot;</span><span class="p">,</span> <span class="s2">&quot;#P&quot;</span><span class="p">,</span> <span class="s2">&quot;#T&quot;</span><span class="p">]:</span>
                <span class="c1"># does not store # in route to avoid error in input</span>
                <span class="k">if</span> <span class="n">tok</span> <span class="o">==</span> <span class="s2">&quot;#&quot;</span><span class="p">:</span>
                    <span class="n">dieze_tag</span> <span class="o">=</span> <span class="s2">&quot;#N&quot;</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">dieze_tag</span> <span class="o">=</span> <span class="n">tok</span>
                <span class="k">continue</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">m</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">multi_params_patt</span><span class="p">,</span> <span class="n">tok</span><span class="o">.</span><span class="n">strip</span><span class="p">(</span><span class="s2">&quot;#&quot;</span><span class="p">))</span>
                <span class="k">if</span> <span class="n">m</span><span class="p">:</span>
                    <span class="n">pars</span> <span class="o">=</span> <span class="p">{}</span>
                    <span class="k">for</span> <span class="n">par</span> <span class="ow">in</span> <span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;,&quot;</span><span class="p">):</span>
                        <span class="n">p</span> <span class="o">=</span> <span class="n">par</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;=&quot;</span><span class="p">)</span>
                        <span class="n">pars</span><span class="p">[</span><span class="n">p</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span> <span class="k">else</span> <span class="n">p</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
                    <span class="n">route_params</span><span class="p">[</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">)]</span> <span class="o">=</span> <span class="n">pars</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">d</span> <span class="o">=</span> <span class="n">tok</span><span class="o">.</span><span class="n">strip</span><span class="p">(</span><span class="s2">&quot;#&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;=&quot;</span><span class="p">)</span>
                    <span class="n">route_params</span><span class="p">[</span><span class="n">d</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">d</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span> <span class="k">else</span> <span class="n">d</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>

    <span class="k">return</span> <span class="n">functional</span><span class="p">,</span> <span class="n">basis_set</span><span class="p">,</span> <span class="n">route_params</span><span class="p">,</span> <span class="n">dieze_tag</span></div>


<div class="viewcode-block" id="GaussianInput"><a class="viewcode-back" href="../../../pymatgen.io.gaussian.html#pymatgen.io.gaussian.GaussianInput">[docs]</a><span class="k">class</span> <span class="nc">GaussianInput</span><span class="p">:</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    An object representing a Gaussian input file.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="c1"># Commonly used regex patterns</span>
    <span class="n">_zmat_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;^(\w+)*([\s,]+(\w+)[\s,]+(\w+))*[\-\.\s,\w]*$&quot;</span><span class="p">)</span>
    <span class="n">_xyz_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;^(\w+)[\s,]+([\d\.eE\-]+)[\s,]+([\d\.eE\-]+)[\s,]+&quot;</span>
                           <span class="sa">r</span><span class="s2">&quot;([\d\.eE\-]+)[\-\.\s,\w.]*$&quot;</span><span class="p">)</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">mol</span><span class="p">,</span> <span class="n">charge</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">spin_multiplicity</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">title</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                 <span class="n">functional</span><span class="o">=</span><span class="s2">&quot;HF&quot;</span><span class="p">,</span> <span class="n">basis_set</span><span class="o">=</span><span class="s2">&quot;6-31G(d)&quot;</span><span class="p">,</span> <span class="n">route_parameters</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                 <span class="n">input_parameters</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">link0_parameters</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">dieze_tag</span><span class="o">=</span><span class="s2">&quot;#P&quot;</span><span class="p">,</span>
                 <span class="n">gen_basis</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            mol: Input molecule. It can either be a Molecule object,</span>
<span class="sd">                a string giving the geometry in a format supported by Guassian,</span>
<span class="sd">                or ``None``. If the molecule is ``None``, you will need to use</span>
<span class="sd">                read it in from a checkpoint. Consider adding ``CHK`` to the</span>
<span class="sd">                ``link0_parameters``.</span>
<span class="sd">            charge: Charge of the molecule. If None, charge on molecule is used.</span>
<span class="sd">                Defaults to None. This allows the input file to be set a</span>
<span class="sd">                charge independently from the molecule itself.</span>
<span class="sd">                If ``mol`` is not a Molecule object, then you must specify a charge.</span>
<span class="sd">            spin_multiplicity: Spin multiplicity of molecule. Defaults to None,</span>
<span class="sd">                which means that the spin multiplicity is set to 1 if the</span>
<span class="sd">                molecule has no unpaired electrons and to 2 if there are</span>
<span class="sd">                unpaired electrons. If ``mol`` is not a Molecule object, then you</span>
<span class="sd">                 must specify the multiplicity</span>
<span class="sd">            title: Title for run. Defaults to formula of molecule if None.</span>
<span class="sd">            functional: Functional for run.</span>
<span class="sd">            basis_set: Basis set for run.</span>
<span class="sd">            route_parameters: Additional route parameters as a dict. For example,</span>
<span class="sd">                {&#39;SP&#39;:&quot;&quot;, &quot;SCF&quot;:&quot;Tight&quot;}</span>
<span class="sd">            input_parameters: Additional input parameters for run as a dict. Used</span>
<span class="sd">                for example, in PCM calculations.  E.g., {&quot;EPS&quot;:12}</span>
<span class="sd">            link0_parameters: Link0 parameters as a dict. E.g., {&quot;%mem&quot;: &quot;1000MW&quot;}</span>
<span class="sd">            dieze_tag: # preceding the route line. E.g. &quot;#p&quot;</span>
<span class="sd">            gen_basis: allows a user-specified basis set to be used in a Gaussian</span>
<span class="sd">                calculation. If this is not None, the attribute ``basis_set`` will</span>
<span class="sd">                be set to &quot;Gen&quot;.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_mol</span> <span class="o">=</span> <span class="n">mol</span>

        <span class="c1"># Determine multiplicity and charge settings</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">mol</span><span class="p">,</span> <span class="n">Molecule</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">charge</span> <span class="o">=</span> <span class="n">charge</span> <span class="k">if</span> <span class="n">charge</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">mol</span><span class="o">.</span><span class="n">charge</span>
            <span class="n">nelectrons</span> <span class="o">=</span> <span class="n">mol</span><span class="o">.</span><span class="n">charge</span> <span class="o">+</span> <span class="n">mol</span><span class="o">.</span><span class="n">nelectrons</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">charge</span>
            <span class="k">if</span> <span class="n">spin_multiplicity</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">spin_multiplicity</span> <span class="o">=</span> <span class="n">spin_multiplicity</span>
                <span class="k">if</span> <span class="p">(</span><span class="n">nelectrons</span> <span class="o">+</span> <span class="n">spin_multiplicity</span><span class="p">)</span> <span class="o">%</span> <span class="mi">2</span> <span class="o">!=</span> <span class="mi">1</span><span class="p">:</span>
                    <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                        <span class="s2">&quot;Charge of </span><span class="si">{}</span><span class="s2"> and spin multiplicity of </span><span class="si">{}</span><span class="s2"> is&quot;</span>
                        <span class="s2">&quot; not possible for this molecule&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                            <span class="bp">self</span><span class="o">.</span><span class="n">charge</span><span class="p">,</span> <span class="n">spin_multiplicity</span><span class="p">))</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">spin_multiplicity</span> <span class="o">=</span> <span class="mi">1</span> <span class="k">if</span> <span class="n">nelectrons</span> <span class="o">%</span> <span class="mi">2</span> <span class="o">==</span> <span class="mi">0</span> <span class="k">else</span> <span class="mi">2</span>

            <span class="c1"># Get a title from the molecule name</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">title</span> <span class="o">=</span> <span class="n">title</span> <span class="k">if</span> <span class="n">title</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">_mol</span><span class="o">.</span><span class="n">composition</span><span class="o">.</span><span class="n">formula</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">charge</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="n">spin_multiplicity</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">&#39;`charge` and `spin_multiplicity` must be specified&#39;</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">charge</span> <span class="o">=</span> <span class="n">charge</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">spin_multiplicity</span> <span class="o">=</span> <span class="n">spin_multiplicity</span>

            <span class="c1"># Set a title</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">title</span> <span class="o">=</span> <span class="n">title</span> <span class="k">if</span> <span class="n">title</span> <span class="k">else</span> <span class="s1">&#39;Restart&#39;</span>

        <span class="c1"># Store the remaining settings</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">functional</span> <span class="o">=</span> <span class="n">functional</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">basis_set</span> <span class="o">=</span> <span class="n">basis_set</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">link0_parameters</span> <span class="o">=</span> <span class="n">link0_parameters</span> <span class="k">if</span> <span class="n">link0_parameters</span> <span class="k">else</span> <span class="p">{}</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">route_parameters</span> <span class="o">=</span> <span class="n">route_parameters</span> <span class="k">if</span> <span class="n">route_parameters</span> <span class="k">else</span> <span class="p">{}</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">input_parameters</span> <span class="o">=</span> <span class="n">input_parameters</span> <span class="k">if</span> <span class="n">input_parameters</span> <span class="k">else</span> <span class="p">{}</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">dieze_tag</span> <span class="o">=</span> <span class="n">dieze_tag</span> <span class="k">if</span> <span class="n">dieze_tag</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s2">&quot;#&quot;</span> <span class="k">else</span> <span class="s2">&quot;#&quot;</span> <span class="o">+</span> <span class="n">dieze_tag</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">gen_basis</span> <span class="o">=</span> <span class="n">gen_basis</span>
        <span class="k">if</span> <span class="n">gen_basis</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">basis_set</span> <span class="o">=</span> <span class="s2">&quot;Gen&quot;</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">molecule</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Returns molecule associated with this GaussianInput.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_mol</span>

    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">_parse_coords</span><span class="p">(</span><span class="n">coord_lines</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Helper method to parse coordinates.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">paras</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="n">var_pattern</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;^([A-Za-z]+\S*)[\s=,]+([\d\-\.]+)$&quot;</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">l</span> <span class="ow">in</span> <span class="n">coord_lines</span><span class="p">:</span>
            <span class="n">m</span> <span class="o">=</span> <span class="n">var_pattern</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">l</span><span class="o">.</span><span class="n">strip</span><span class="p">())</span>
            <span class="k">if</span> <span class="n">m</span><span class="p">:</span>
                <span class="n">paras</span><span class="p">[</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">(</span><span class="s2">&quot;=&quot;</span><span class="p">)]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">2</span><span class="p">))</span>

        <span class="n">species</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">coords</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="c1"># Stores whether a Zmatrix format is detected. Once a zmatrix format</span>
        <span class="c1"># is detected, it is assumed for the remaining of the parsing.</span>
        <span class="n">zmode</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="k">for</span> <span class="n">l</span> <span class="ow">in</span> <span class="n">coord_lines</span><span class="p">:</span>
            <span class="n">l</span> <span class="o">=</span> <span class="n">l</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="n">l</span><span class="p">:</span>
                <span class="k">break</span>
            <span class="k">if</span> <span class="p">(</span><span class="ow">not</span> <span class="n">zmode</span><span class="p">)</span> <span class="ow">and</span> <span class="n">GaussianInput</span><span class="o">.</span><span class="n">_xyz_patt</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">l</span><span class="p">):</span>
                <span class="n">m</span> <span class="o">=</span> <span class="n">GaussianInput</span><span class="o">.</span><span class="n">_xyz_patt</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">l</span><span class="p">)</span>
                <span class="n">species</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">))</span>
                <span class="n">toks</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;[,\s]+&quot;</span><span class="p">,</span> <span class="n">l</span><span class="o">.</span><span class="n">strip</span><span class="p">())</span>
                <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">toks</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">4</span><span class="p">:</span>
                    <span class="n">coords</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="nb">float</span><span class="p">(</span><span class="n">i</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">toks</span><span class="p">[</span><span class="mi">2</span><span class="p">:</span><span class="mi">5</span><span class="p">]])</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">coords</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="nb">float</span><span class="p">(</span><span class="n">i</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">toks</span><span class="p">[</span><span class="mi">1</span><span class="p">:</span><span class="mi">4</span><span class="p">]])</span>
            <span class="k">elif</span> <span class="n">GaussianInput</span><span class="o">.</span><span class="n">_zmat_patt</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">l</span><span class="p">):</span>
                <span class="n">zmode</span> <span class="o">=</span> <span class="kc">True</span>
                <span class="n">toks</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;[,\s]+&quot;</span><span class="p">,</span> <span class="n">l</span><span class="o">.</span><span class="n">strip</span><span class="p">())</span>
                <span class="n">species</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">toks</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
                <span class="n">toks</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
                <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">toks</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                    <span class="n">coords</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">]))</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">nn</span> <span class="o">=</span> <span class="p">[]</span>
                    <span class="n">parameters</span> <span class="o">=</span> <span class="p">[]</span>
                    <span class="k">while</span> <span class="nb">len</span><span class="p">(</span><span class="n">toks</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
                        <span class="n">ind</span> <span class="o">=</span> <span class="n">toks</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
                        <span class="n">data</span> <span class="o">=</span> <span class="n">toks</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
                        <span class="k">try</span><span class="p">:</span>
                            <span class="n">nn</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">ind</span><span class="p">))</span>
                        <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
                            <span class="n">nn</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">species</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="n">ind</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
                        <span class="k">try</span><span class="p">:</span>
                            <span class="n">val</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
                            <span class="n">parameters</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">val</span><span class="p">)</span>
                        <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
                            <span class="k">if</span> <span class="n">data</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">&quot;-&quot;</span><span class="p">):</span>
                                <span class="n">parameters</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="o">-</span><span class="n">paras</span><span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="mi">1</span><span class="p">:]])</span>
                            <span class="k">else</span><span class="p">:</span>
                                <span class="n">parameters</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">paras</span><span class="p">[</span><span class="n">data</span><span class="p">])</span>
                    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">nn</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
                        <span class="n">coords</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">0</span><span class="p">]]))</span>
                    <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">nn</span><span class="p">)</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span>
                        <span class="n">coords1</span> <span class="o">=</span> <span class="n">coords</span><span class="p">[</span><span class="n">nn</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span>
                        <span class="n">coords2</span> <span class="o">=</span> <span class="n">coords</span><span class="p">[</span><span class="n">nn</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span>
                        <span class="n">bl</span> <span class="o">=</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
                        <span class="n">angle</span> <span class="o">=</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
                        <span class="n">axis</span> <span class="o">=</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">]</span>
                        <span class="n">op</span> <span class="o">=</span> <span class="n">SymmOp</span><span class="o">.</span><span class="n">from_origin_axis_angle</span><span class="p">(</span><span class="n">coords1</span><span class="p">,</span> <span class="n">axis</span><span class="p">,</span>
                                                           <span class="n">angle</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span>
                        <span class="n">coord</span> <span class="o">=</span> <span class="n">op</span><span class="o">.</span><span class="n">operate</span><span class="p">(</span><span class="n">coords2</span><span class="p">)</span>
                        <span class="n">vec</span> <span class="o">=</span> <span class="n">coord</span> <span class="o">-</span> <span class="n">coords1</span>
                        <span class="n">coord</span> <span class="o">=</span> <span class="n">vec</span> <span class="o">*</span> <span class="n">bl</span> <span class="o">/</span> <span class="n">np</span><span class="o">.</span><span class="n">linalg</span><span class="o">.</span><span class="n">norm</span><span class="p">(</span><span class="n">vec</span><span class="p">)</span> <span class="o">+</span> <span class="n">coords1</span>
                        <span class="n">coords</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">coord</span><span class="p">)</span>
                    <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">nn</span><span class="p">)</span> <span class="o">==</span> <span class="mi">3</span><span class="p">:</span>
                        <span class="n">coords1</span> <span class="o">=</span> <span class="n">coords</span><span class="p">[</span><span class="n">nn</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span>
                        <span class="n">coords2</span> <span class="o">=</span> <span class="n">coords</span><span class="p">[</span><span class="n">nn</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span>
                        <span class="n">coords3</span> <span class="o">=</span> <span class="n">coords</span><span class="p">[</span><span class="n">nn</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span>
                        <span class="n">bl</span> <span class="o">=</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
                        <span class="n">angle</span> <span class="o">=</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
                        <span class="n">dih</span> <span class="o">=</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span>
                        <span class="n">v1</span> <span class="o">=</span> <span class="n">coords3</span> <span class="o">-</span> <span class="n">coords2</span>
                        <span class="n">v2</span> <span class="o">=</span> <span class="n">coords1</span> <span class="o">-</span> <span class="n">coords2</span>
                        <span class="n">axis</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">cross</span><span class="p">(</span><span class="n">v1</span><span class="p">,</span> <span class="n">v2</span><span class="p">)</span>
                        <span class="n">op</span> <span class="o">=</span> <span class="n">SymmOp</span><span class="o">.</span><span class="n">from_origin_axis_angle</span><span class="p">(</span>
                            <span class="n">coords1</span><span class="p">,</span> <span class="n">axis</span><span class="p">,</span> <span class="n">angle</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span>
                        <span class="n">coord</span> <span class="o">=</span> <span class="n">op</span><span class="o">.</span><span class="n">operate</span><span class="p">(</span><span class="n">coords2</span><span class="p">)</span>
                        <span class="n">v1</span> <span class="o">=</span> <span class="n">coord</span> <span class="o">-</span> <span class="n">coords1</span>
                        <span class="n">v2</span> <span class="o">=</span> <span class="n">coords1</span> <span class="o">-</span> <span class="n">coords2</span>
                        <span class="n">v3</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">cross</span><span class="p">(</span><span class="n">v1</span><span class="p">,</span> <span class="n">v2</span><span class="p">)</span>
                        <span class="n">adj</span> <span class="o">=</span> <span class="n">get_angle</span><span class="p">(</span><span class="n">v3</span><span class="p">,</span> <span class="n">axis</span><span class="p">)</span>
                        <span class="n">axis</span> <span class="o">=</span> <span class="n">coords1</span> <span class="o">-</span> <span class="n">coords2</span>
                        <span class="n">op</span> <span class="o">=</span> <span class="n">SymmOp</span><span class="o">.</span><span class="n">from_origin_axis_angle</span><span class="p">(</span>
                            <span class="n">coords1</span><span class="p">,</span> <span class="n">axis</span><span class="p">,</span> <span class="n">dih</span> <span class="o">-</span> <span class="n">adj</span><span class="p">,</span> <span class="kc">False</span><span class="p">)</span>
                        <span class="n">coord</span> <span class="o">=</span> <span class="n">op</span><span class="o">.</span><span class="n">operate</span><span class="p">(</span><span class="n">coord</span><span class="p">)</span>
                        <span class="n">vec</span> <span class="o">=</span> <span class="n">coord</span> <span class="o">-</span> <span class="n">coords1</span>
                        <span class="n">coord</span> <span class="o">=</span> <span class="n">vec</span> <span class="o">*</span> <span class="n">bl</span> <span class="o">/</span> <span class="n">np</span><span class="o">.</span><span class="n">linalg</span><span class="o">.</span><span class="n">norm</span><span class="p">(</span><span class="n">vec</span><span class="p">)</span> <span class="o">+</span> <span class="n">coords1</span>
                        <span class="n">coords</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">coord</span><span class="p">)</span>

        <span class="k">def</span> <span class="nf">_parse_species</span><span class="p">(</span><span class="n">sp_str</span><span class="p">):</span>
            <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">            The species specification can take many forms. E.g.,</span>
<span class="sd">            simple integers representing atomic numbers (&quot;8&quot;),</span>
<span class="sd">            actual species string (&quot;C&quot;) or a labelled species (&quot;C1&quot;).</span>
<span class="sd">            Sometimes, the species string is also not properly capitalized,</span>
<span class="sd">            e.g, (&quot;c1&quot;). This method should take care of these known formats.</span>
<span class="sd">            &quot;&quot;&quot;</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="k">return</span> <span class="nb">int</span><span class="p">(</span><span class="n">sp_str</span><span class="p">)</span>
            <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
                <span class="n">sp</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">sub</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;\d&quot;</span><span class="p">,</span> <span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="n">sp_str</span><span class="p">)</span>
                <span class="k">return</span> <span class="n">sp</span><span class="o">.</span><span class="n">capitalize</span><span class="p">()</span>

        <span class="n">species</span> <span class="o">=</span> <span class="p">[</span><span class="n">_parse_species</span><span class="p">(</span><span class="n">sp</span><span class="p">)</span> <span class="k">for</span> <span class="n">sp</span> <span class="ow">in</span> <span class="n">species</span><span class="p">]</span>

        <span class="k">return</span> <span class="n">Molecule</span><span class="p">(</span><span class="n">species</span><span class="p">,</span> <span class="n">coords</span><span class="p">)</span>

<div class="viewcode-block" id="GaussianInput.from_string"><a class="viewcode-back" href="../../../pymatgen.io.gaussian.html#pymatgen.io.gaussian.GaussianInput.from_string">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">from_string</span><span class="p">(</span><span class="n">contents</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Creates GaussianInput from a string.</span>

<span class="sd">        Args:</span>
<span class="sd">            contents: String representing an Gaussian input file.</span>

<span class="sd">        Returns:</span>
<span class="sd">            GaussianInput object</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">lines</span> <span class="o">=</span> <span class="p">[</span><span class="n">l</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">for</span> <span class="n">l</span> <span class="ow">in</span> <span class="n">contents</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">)]</span>

        <span class="n">link0_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;^(%.+)\s*=\s*(.+)&quot;</span><span class="p">)</span>
        <span class="n">link0_dict</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">l</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">lines</span><span class="p">):</span>
            <span class="k">if</span> <span class="n">link0_patt</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">l</span><span class="p">):</span>
                <span class="n">m</span> <span class="o">=</span> <span class="n">link0_patt</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">l</span><span class="p">)</span>
                <span class="n">link0_dict</span><span class="p">[</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">(</span><span class="s2">&quot;=&quot;</span><span class="p">)]</span> <span class="o">=</span> <span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>

        <span class="n">route_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;^#[sSpPnN]*.*&quot;</span><span class="p">)</span>
        <span class="n">route</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span>
        <span class="n">route_index</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">l</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">lines</span><span class="p">):</span>
            <span class="k">if</span> <span class="n">route_patt</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">l</span><span class="p">):</span>
                <span class="n">route</span> <span class="o">+=</span> <span class="s2">&quot; &quot;</span> <span class="o">+</span> <span class="n">l</span>
                <span class="n">route_index</span> <span class="o">=</span> <span class="n">i</span>
            <span class="c1"># This condition allows for route cards spanning multiple lines</span>
            <span class="k">elif</span> <span class="p">(</span><span class="n">l</span> <span class="o">==</span> <span class="s2">&quot;&quot;</span> <span class="ow">or</span> <span class="n">l</span><span class="o">.</span><span class="n">isspace</span><span class="p">())</span> <span class="ow">and</span> <span class="n">route_index</span><span class="p">:</span>
                <span class="k">break</span>
        <span class="n">functional</span><span class="p">,</span> <span class="n">basis_set</span><span class="p">,</span> <span class="n">route_paras</span><span class="p">,</span> <span class="n">dieze_tag</span> <span class="o">=</span> <span class="n">read_route_line</span><span class="p">(</span><span class="n">route</span><span class="p">)</span>
        <span class="n">ind</span> <span class="o">=</span> <span class="mi">2</span>
        <span class="n">title</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">while</span> <span class="n">lines</span><span class="p">[</span><span class="n">route_index</span> <span class="o">+</span> <span class="n">ind</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">():</span>
            <span class="n">title</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">lines</span><span class="p">[</span><span class="n">route_index</span> <span class="o">+</span> <span class="n">ind</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">())</span>
            <span class="n">ind</span> <span class="o">+=</span> <span class="mi">1</span>
        <span class="n">title</span> <span class="o">=</span> <span class="s1">&#39; &#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">title</span><span class="p">)</span>
        <span class="n">ind</span> <span class="o">+=</span> <span class="mi">1</span>
        <span class="n">toks</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;[,\s]+&quot;</span><span class="p">,</span> <span class="n">lines</span><span class="p">[</span><span class="n">route_index</span> <span class="o">+</span> <span class="n">ind</span><span class="p">])</span>
        <span class="n">charge</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="nb">float</span><span class="p">(</span><span class="n">toks</span><span class="p">[</span><span class="mi">0</span><span class="p">]))</span>
        <span class="n">spin_mult</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">toks</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
        <span class="n">coord_lines</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">spaces</span> <span class="o">=</span> <span class="mi">0</span>
        <span class="n">input_paras</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="n">ind</span> <span class="o">+=</span> <span class="mi">1</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">route_index</span> <span class="o">+</span> <span class="n">ind</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">lines</span><span class="p">)):</span>
            <span class="k">if</span> <span class="n">lines</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;&quot;</span><span class="p">:</span>
                <span class="n">spaces</span> <span class="o">+=</span> <span class="mi">1</span>
            <span class="k">if</span> <span class="n">spaces</span> <span class="o">&gt;=</span> <span class="mi">2</span><span class="p">:</span>
                <span class="n">d</span> <span class="o">=</span> <span class="n">lines</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;=&quot;</span><span class="p">)</span>
                <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">d</span><span class="p">)</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span>
                    <span class="n">input_paras</span><span class="p">[</span><span class="n">d</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span> <span class="o">=</span> <span class="n">d</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">coord_lines</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">lines</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">())</span>
        <span class="n">mol</span> <span class="o">=</span> <span class="n">GaussianInput</span><span class="o">.</span><span class="n">_parse_coords</span><span class="p">(</span><span class="n">coord_lines</span><span class="p">)</span>
        <span class="n">mol</span><span class="o">.</span><span class="n">set_charge_and_spin</span><span class="p">(</span><span class="n">charge</span><span class="p">,</span> <span class="n">spin_mult</span><span class="p">)</span>

        <span class="k">return</span> <span class="n">GaussianInput</span><span class="p">(</span><span class="n">mol</span><span class="p">,</span> <span class="n">charge</span><span class="o">=</span><span class="n">charge</span><span class="p">,</span> <span class="n">spin_multiplicity</span><span class="o">=</span><span class="n">spin_mult</span><span class="p">,</span>
                             <span class="n">title</span><span class="o">=</span><span class="n">title</span><span class="p">,</span> <span class="n">functional</span><span class="o">=</span><span class="n">functional</span><span class="p">,</span>
                             <span class="n">basis_set</span><span class="o">=</span><span class="n">basis_set</span><span class="p">,</span>
                             <span class="n">route_parameters</span><span class="o">=</span><span class="n">route_paras</span><span class="p">,</span>
                             <span class="n">input_parameters</span><span class="o">=</span><span class="n">input_paras</span><span class="p">,</span>
                             <span class="n">link0_parameters</span><span class="o">=</span><span class="n">link0_dict</span><span class="p">,</span>
                             <span class="n">dieze_tag</span><span class="o">=</span><span class="n">dieze_tag</span><span class="p">)</span></div>

<div class="viewcode-block" id="GaussianInput.from_file"><a class="viewcode-back" href="../../../pymatgen.io.gaussian.html#pymatgen.io.gaussian.GaussianInput.from_file">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">from_file</span><span class="p">(</span><span class="n">filename</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Creates GaussianInput from a file.</span>

<span class="sd">        Args:</span>
<span class="sd">            filename: Gaussian input filename</span>

<span class="sd">        Returns:</span>
<span class="sd">            GaussianInput object</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">with</span> <span class="n">zopen</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="s2">&quot;r&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">GaussianInput</span><span class="o">.</span><span class="n">from_string</span><span class="p">(</span><span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">())</span></div>

    <span class="k">def</span> <span class="nf">_find_nn_pos_before_site</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">siteindex</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Returns index of nearest neighbor atoms.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">alldist</span> <span class="o">=</span> <span class="p">[(</span><span class="bp">self</span><span class="o">.</span><span class="n">_mol</span><span class="o">.</span><span class="n">get_distance</span><span class="p">(</span><span class="n">siteindex</span><span class="p">,</span> <span class="n">i</span><span class="p">),</span> <span class="n">i</span><span class="p">)</span>
                   <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">siteindex</span><span class="p">)]</span>
        <span class="n">alldist</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">alldist</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">x</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
        <span class="k">return</span> <span class="p">[</span><span class="n">d</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="k">for</span> <span class="n">d</span> <span class="ow">in</span> <span class="n">alldist</span><span class="p">]</span>

<div class="viewcode-block" id="GaussianInput.get_zmatrix"><a class="viewcode-back" href="../../../pymatgen.io.gaussian.html#pymatgen.io.gaussian.GaussianInput.get_zmatrix">[docs]</a>    <span class="k">def</span> <span class="nf">get_zmatrix</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Returns a z-matrix representation of the molecule.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">output</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">outputvar</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">site</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_mol</span><span class="p">):</span>
            <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                <span class="n">output</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">site</span><span class="o">.</span><span class="n">specie</span><span class="p">))</span>
            <span class="k">elif</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
                <span class="n">nn</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_find_nn_pos_before_site</span><span class="p">(</span><span class="n">i</span><span class="p">)</span>
                <span class="n">bondlength</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_mol</span><span class="o">.</span><span class="n">get_distance</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">nn</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
                <span class="n">output</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">{}</span><span class="s2"> </span><span class="si">{}</span><span class="s2"> B</span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_mol</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">specie</span><span class="p">,</span>
                                                 <span class="n">nn</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">i</span><span class="p">))</span>
                <span class="n">outputvar</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;B</span><span class="si">{}</span><span class="s2">=</span><span class="si">{:.6f}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">bondlength</span><span class="p">))</span>
            <span class="k">elif</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span>
                <span class="n">nn</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_find_nn_pos_before_site</span><span class="p">(</span><span class="n">i</span><span class="p">)</span>
                <span class="n">bondlength</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_mol</span><span class="o">.</span><span class="n">get_distance</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">nn</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
                <span class="n">angle</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_mol</span><span class="o">.</span><span class="n">get_angle</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">nn</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">nn</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
                <span class="n">output</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">{}</span><span class="s2"> </span><span class="si">{}</span><span class="s2"> B</span><span class="si">{}</span><span class="s2"> </span><span class="si">{}</span><span class="s2"> A</span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_mol</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">specie</span><span class="p">,</span>
                                                        <span class="n">nn</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">i</span><span class="p">,</span>
                                                        <span class="n">nn</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">i</span><span class="p">))</span>
                <span class="n">outputvar</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;B</span><span class="si">{}</span><span class="s2">=</span><span class="si">{:.6f}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">bondlength</span><span class="p">))</span>
                <span class="n">outputvar</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;A</span><span class="si">{}</span><span class="s2">=</span><span class="si">{:.6f}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">angle</span><span class="p">))</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">nn</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_find_nn_pos_before_site</span><span class="p">(</span><span class="n">i</span><span class="p">)</span>
                <span class="n">bondlength</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_mol</span><span class="o">.</span><span class="n">get_distance</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">nn</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
                <span class="n">angle</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_mol</span><span class="o">.</span><span class="n">get_angle</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">nn</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">nn</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
                <span class="n">dih</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_mol</span><span class="o">.</span><span class="n">get_dihedral</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">nn</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">nn</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">nn</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span>
                <span class="n">output</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">{}</span><span class="s2"> </span><span class="si">{}</span><span class="s2"> B</span><span class="si">{}</span><span class="s2"> </span><span class="si">{}</span><span class="s2"> A</span><span class="si">{}</span><span class="s2"> </span><span class="si">{}</span><span class="s2"> D</span><span class="si">{}</span><span class="s2">&quot;</span>
                              <span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_mol</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">specie</span><span class="p">,</span> <span class="n">nn</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">i</span><span class="p">,</span>
                                      <span class="n">nn</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">i</span><span class="p">,</span> <span class="n">nn</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">i</span><span class="p">))</span>
                <span class="n">outputvar</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;B</span><span class="si">{}</span><span class="s2">=</span><span class="si">{:.6f}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">bondlength</span><span class="p">))</span>
                <span class="n">outputvar</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;A</span><span class="si">{}</span><span class="s2">=</span><span class="si">{:.6f}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">angle</span><span class="p">))</span>
                <span class="n">outputvar</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;D</span><span class="si">{}</span><span class="s2">=</span><span class="si">{:.6f}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">dih</span><span class="p">))</span>
        <span class="k">return</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">output</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot;</span><span class="se">\n\n</span><span class="s2">&quot;</span> <span class="o">+</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">outputvar</span><span class="p">)</span></div>

<div class="viewcode-block" id="GaussianInput.get_cart_coords"><a class="viewcode-back" href="../../../pymatgen.io.gaussian.html#pymatgen.io.gaussian.GaussianInput.get_cart_coords">[docs]</a>    <span class="k">def</span> <span class="nf">get_cart_coords</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Return the cartesian coordinates of the molecule</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">def</span> <span class="nf">to_s</span><span class="p">(</span><span class="n">x</span><span class="p">):</span>
            <span class="k">return</span> <span class="s2">&quot;</span><span class="si">%0.6f</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="n">x</span>

        <span class="n">outs</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">site</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_mol</span><span class="p">):</span>
            <span class="n">outs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot; &quot;</span><span class="o">.</span><span class="n">join</span><span class="p">([</span><span class="n">site</span><span class="o">.</span><span class="n">species_string</span><span class="p">,</span>
                                  <span class="s2">&quot; &quot;</span><span class="o">.</span><span class="n">join</span><span class="p">([</span><span class="n">to_s</span><span class="p">(</span><span class="n">j</span><span class="p">)</span> <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="n">site</span><span class="o">.</span><span class="n">coords</span><span class="p">])]))</span>
        <span class="k">return</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">outs</span><span class="p">)</span></div>

    <span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">to_string</span><span class="p">()</span>

<div class="viewcode-block" id="GaussianInput.to_string"><a class="viewcode-back" href="../../../pymatgen.io.gaussian.html#pymatgen.io.gaussian.GaussianInput.to_string">[docs]</a>    <span class="k">def</span> <span class="nf">to_string</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">cart_coords</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Return GaussianInput string</span>

<span class="sd">        Option: whe cart_coords sets to True return the cartesian coordinates</span>
<span class="sd">                instead of the z-matrix</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">def</span> <span class="nf">para_dict_to_string</span><span class="p">(</span><span class="n">para</span><span class="p">,</span> <span class="n">joiner</span><span class="o">=</span><span class="s2">&quot; &quot;</span><span class="p">):</span>
            <span class="n">para_str</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="c1"># sorted is only done to make unittests work reliably</span>
            <span class="k">for</span> <span class="n">par</span><span class="p">,</span> <span class="n">val</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">para</span><span class="o">.</span><span class="n">items</span><span class="p">()):</span>
                <span class="k">if</span> <span class="n">val</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="n">val</span> <span class="o">==</span> <span class="s2">&quot;&quot;</span><span class="p">:</span>
                    <span class="n">para_str</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">par</span><span class="p">)</span>
                <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">val</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span>
                    <span class="n">val_str</span> <span class="o">=</span> <span class="n">para_dict_to_string</span><span class="p">(</span><span class="n">val</span><span class="p">,</span> <span class="n">joiner</span><span class="o">=</span><span class="s2">&quot;,&quot;</span><span class="p">)</span>
                    <span class="n">para_str</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">{}</span><span class="s2">=(</span><span class="si">{}</span><span class="s2">)&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">par</span><span class="p">,</span> <span class="n">val_str</span><span class="p">))</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">para_str</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">{}</span><span class="s2">=</span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">par</span><span class="p">,</span> <span class="n">val</span><span class="p">))</span>
            <span class="k">return</span> <span class="n">joiner</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">para_str</span><span class="p">)</span>

        <span class="n">output</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">link0_parameters</span><span class="p">:</span>
            <span class="n">output</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">para_dict_to_string</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">link0_parameters</span><span class="p">,</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">))</span>
        <span class="n">output</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">{diez}</span><span class="s2"> </span><span class="si">{func}</span><span class="s2">/</span><span class="si">{bset}</span><span class="s2"> </span><span class="si">{route}</span><span class="s2">&quot;</span>
                      <span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">diez</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">dieze_tag</span><span class="p">,</span> <span class="n">func</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">functional</span><span class="p">,</span>
                              <span class="n">bset</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">basis_set</span><span class="p">,</span>
                              <span class="n">route</span><span class="o">=</span><span class="n">para_dict_to_string</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">route_parameters</span><span class="p">))</span>
                      <span class="p">)</span>
        <span class="n">output</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
        <span class="n">output</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">title</span><span class="p">)</span>
        <span class="n">output</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
        <span class="n">output</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">%d</span><span class="s2"> </span><span class="si">%d</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">charge</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">spin_multiplicity</span><span class="p">))</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_mol</span><span class="p">,</span> <span class="n">Molecule</span><span class="p">):</span>
            <span class="k">if</span> <span class="n">cart_coords</span> <span class="ow">is</span> <span class="kc">True</span><span class="p">:</span>
                <span class="n">output</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">get_cart_coords</span><span class="p">())</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">output</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">get_zmatrix</span><span class="p">())</span>
        <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_mol</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">output</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_mol</span><span class="p">))</span>
        <span class="n">output</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">gen_basis</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">output</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">{:s}</span><span class="se">\n</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">gen_basis</span><span class="p">))</span>
        <span class="n">output</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">para_dict_to_string</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">input_parameters</span><span class="p">,</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">))</span>
        <span class="n">output</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">)</span>
        <span class="k">return</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">output</span><span class="p">)</span></div>

<div class="viewcode-block" id="GaussianInput.write_file"><a class="viewcode-back" href="../../../pymatgen.io.gaussian.html#pymatgen.io.gaussian.GaussianInput.write_file">[docs]</a>    <span class="k">def</span> <span class="nf">write_file</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="p">,</span> <span class="n">cart_coords</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Write the input string into a file</span>

<span class="sd">        Option: see __str__ method</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">with</span> <span class="n">zopen</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="s2">&quot;w&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
            <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">to_string</span><span class="p">(</span><span class="n">cart_coords</span><span class="p">))</span></div>

<div class="viewcode-block" id="GaussianInput.as_dict"><a class="viewcode-back" href="../../../pymatgen.io.gaussian.html#pymatgen.io.gaussian.GaussianInput.as_dict">[docs]</a>    <span class="k">def</span> <span class="nf">as_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :return: MSONable dict</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="p">{</span><span class="s2">&quot;@module&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__module__</span><span class="p">,</span>
                <span class="s2">&quot;@class&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="p">,</span>
                <span class="s2">&quot;molecule&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">molecule</span><span class="o">.</span><span class="n">as_dict</span><span class="p">(),</span>
                <span class="s2">&quot;functional&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">functional</span><span class="p">,</span>
                <span class="s2">&quot;basis_set&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">basis_set</span><span class="p">,</span>
                <span class="s2">&quot;route_parameters&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">route_parameters</span><span class="p">,</span>
                <span class="s2">&quot;title&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">title</span><span class="p">,</span>
                <span class="s2">&quot;charge&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">charge</span><span class="p">,</span>
                <span class="s2">&quot;spin_multiplicity&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">spin_multiplicity</span><span class="p">,</span>
                <span class="s2">&quot;input_parameters&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">input_parameters</span><span class="p">,</span>
                <span class="s2">&quot;link0_parameters&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">link0_parameters</span><span class="p">,</span>
                <span class="s2">&quot;dieze_tag&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">dieze_tag</span><span class="p">}</span></div>

<div class="viewcode-block" id="GaussianInput.from_dict"><a class="viewcode-back" href="../../../pymatgen.io.gaussian.html#pymatgen.io.gaussian.GaussianInput.from_dict">[docs]</a>    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">from_dict</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">d</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :param d: dict</span>
<span class="sd">        :return: GaussianInput</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="n">GaussianInput</span><span class="p">(</span><span class="n">mol</span><span class="o">=</span><span class="n">Molecule</span><span class="o">.</span><span class="n">from_dict</span><span class="p">(</span><span class="n">d</span><span class="p">[</span><span class="s2">&quot;molecule&quot;</span><span class="p">]),</span>
                             <span class="n">functional</span><span class="o">=</span><span class="n">d</span><span class="p">[</span><span class="s2">&quot;functional&quot;</span><span class="p">],</span>
                             <span class="n">basis_set</span><span class="o">=</span><span class="n">d</span><span class="p">[</span><span class="s2">&quot;basis_set&quot;</span><span class="p">],</span>
                             <span class="n">route_parameters</span><span class="o">=</span><span class="n">d</span><span class="p">[</span><span class="s2">&quot;route_parameters&quot;</span><span class="p">],</span>
                             <span class="n">title</span><span class="o">=</span><span class="n">d</span><span class="p">[</span><span class="s2">&quot;title&quot;</span><span class="p">],</span>
                             <span class="n">charge</span><span class="o">=</span><span class="n">d</span><span class="p">[</span><span class="s2">&quot;charge&quot;</span><span class="p">],</span>
                             <span class="n">spin_multiplicity</span><span class="o">=</span><span class="n">d</span><span class="p">[</span><span class="s2">&quot;spin_multiplicity&quot;</span><span class="p">],</span>
                             <span class="n">input_parameters</span><span class="o">=</span><span class="n">d</span><span class="p">[</span><span class="s2">&quot;input_parameters&quot;</span><span class="p">],</span>
                             <span class="n">link0_parameters</span><span class="o">=</span><span class="n">d</span><span class="p">[</span><span class="s2">&quot;link0_parameters&quot;</span><span class="p">])</span></div></div>


<div class="viewcode-block" id="GaussianOutput"><a class="viewcode-back" href="../../../pymatgen.io.gaussian.html#pymatgen.io.gaussian.GaussianOutput">[docs]</a><span class="k">class</span> <span class="nc">GaussianOutput</span><span class="p">:</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Parser for Gaussian output files.</span>

<span class="sd">    .. note::</span>

<span class="sd">        Still in early beta.</span>

<span class="sd">    Attributes:</span>

<span class="sd">    .. attribute:: structures</span>

<span class="sd">        All structures from the calculation in the standard orientation. If the</span>
<span class="sd">        symmetry is not considered, the standard orientation is not printed out</span>
<span class="sd">        and the input orientation is used instead. Check the `standard_orientation`</span>
<span class="sd">        attribute.</span>

<span class="sd">    .. attribute:: structures_input_orientation</span>

<span class="sd">        All structures from the calculation in the input orientation or the</span>
<span class="sd">        Z-matrix orientation (if an opt=z-matrix was requested).</span>

<span class="sd">    .. attribute:: opt_structures</span>

<span class="sd">        All optimized structures from the calculation in the input orientation</span>
<span class="sd">        or the Z-matrix orientation.</span>

<span class="sd">    .. attribute:: energies</span>

<span class="sd">        All energies from the calculation.</span>

<span class="sd">    .. attribute:: eigenvalues</span>

<span class="sd">        List of eigenvalues for the last geometry</span>

<span class="sd">    .. attribute:: MO_coefficients</span>

<span class="sd">        Matrix of MO coefficients for the last geometry</span>

<span class="sd">    .. attribute:: cart_forces</span>

<span class="sd">        All cartesian forces from the calculation.</span>

<span class="sd">    .. attribute:: frequencies</span>

<span class="sd">        A list for each freq calculation and for each mode of a dict with</span>
<span class="sd">        {</span>
<span class="sd">            &quot;frequency&quot;: freq in cm-1,</span>
<span class="sd">            &quot;symmetry&quot;: symmetry tag</span>
<span class="sd">            &quot;r_mass&quot;: Reduce mass,</span>
<span class="sd">            &quot;f_constant&quot;: force constant,</span>
<span class="sd">            &quot;IR_intensity&quot;: IR Intensity,</span>
<span class="sd">            &quot;mode&quot;: normal mode</span>
<span class="sd">         }</span>

<span class="sd">        The normal mode is a 1D vector of dx, dy dz of each atom.</span>

<span class="sd">    .. attribute:: hessian</span>

<span class="sd">        Matrix of second derivatives of the energy with respect to cartesian</span>
<span class="sd">        coordinates in the **input orientation** frame. Need #P in the</span>
<span class="sd">        route section in order to be in the output.</span>

<span class="sd">    .. attribute:: properly_terminated</span>

<span class="sd">        True if run has properly terminated</span>

<span class="sd">    .. attribute:: is_pcm</span>

<span class="sd">        True if run is a PCM run.</span>

<span class="sd">    .. attribute:: is_spin</span>

<span class="sd">        True if it is an unrestricted run</span>

<span class="sd">    .. attribute:: stationary_type</span>

<span class="sd">        If it is a relaxation run, indicates whether it is a minimum (Minimum)</span>
<span class="sd">        or a saddle point (&quot;Saddle&quot;).</span>

<span class="sd">    .. attribute:: corrections</span>

<span class="sd">        Thermochemical corrections if this run is a Freq run as a dict. Keys</span>
<span class="sd">        are &quot;Zero-point&quot;, &quot;Thermal&quot;, &quot;Enthalpy&quot; and &quot;Gibbs Free Energy&quot;</span>

<span class="sd">    .. attribute:: functional</span>

<span class="sd">        Functional used in the run.</span>

<span class="sd">    .. attribute:: basis_set</span>

<span class="sd">        Basis set used in the run</span>

<span class="sd">    .. attribute:: route</span>

<span class="sd">        Additional route parameters as a dict. For example,</span>
<span class="sd">            {&#39;SP&#39;:&quot;&quot;, &quot;SCF&quot;:&quot;Tight&quot;}</span>

<span class="sd">    .. attribute:: dieze_tag</span>

<span class="sd">        # preceding the route line, e.g. &quot;#P&quot;</span>

<span class="sd">    .. attribute:: link0</span>

<span class="sd">        Link0 parameters as a dict. E.g., {&quot;%mem&quot;: &quot;1000MW&quot;}</span>

<span class="sd">    .. attribute:: charge</span>

<span class="sd">        Charge for structure</span>

<span class="sd">    .. attribute:: spin_multiplicity</span>

<span class="sd">        Spin multiplicity for structure</span>

<span class="sd">    .. attribute:: num_basis_func</span>

<span class="sd">        Number of basis functions in the run.</span>

<span class="sd">    .. attribute:: electrons</span>

<span class="sd">        number of alpha and beta electrons as (N alpha, N beta)</span>

<span class="sd">    .. attribute:: pcm</span>

<span class="sd">        PCM parameters and output if available.</span>

<span class="sd">    .. attribute:: errors</span>

<span class="sd">        error if not properly terminated (list to be completed in error_defs)</span>

<span class="sd">    .. attribute:: Mulliken_charges</span>

<span class="sd">        Mulliken atomic charges</span>

<span class="sd">    .. attribute:: eigenvectors</span>

<span class="sd">        Matrix of shape (num_basis_func, num_basis_func). Each column is an</span>
<span class="sd">        eigenvectors and contains AO coefficients of an MO.</span>

<span class="sd">        eigenvectors[Spin] = mat(num_basis_func, num_basis_func)</span>

<span class="sd">    .. attribute:: molecular_orbital</span>

<span class="sd">        MO development coefficients on AO in a more convenient array dict</span>
<span class="sd">        for each atom and basis set label.</span>

<span class="sd">        mo[Spin][OM j][atom i] = {AO_k: coeff, AO_k: coeff ... }</span>

<span class="sd">    .. attribute:: atom_basis_labels</span>

<span class="sd">        Labels of AO for each atoms. These labels are those used in the output</span>
<span class="sd">        of molecular orbital coefficients (POP=Full) and in the</span>
<span class="sd">        molecular_orbital array dict.</span>

<span class="sd">        atom_basis_labels[iatom] = [AO_k, AO_k, ...]</span>

<span class="sd">    .. attribute:: resumes</span>

<span class="sd">        List of gaussian data resume given at the end of the output file before</span>
<span class="sd">        the quotation. The resumes are given as string.</span>

<span class="sd">    .. attribute:: title</span>

<span class="sd">        Title of the gaussian run.</span>

<span class="sd">    .. attribute:: standard_orientation</span>

<span class="sd">        If True, the geometries stored in the structures are in the standard</span>
<span class="sd">        orientation. Else, the geometries are in the input orientation.</span>

<span class="sd">    .. attribute:: bond_orders</span>

<span class="sd">        Dict of bond order values read in the output file such as:</span>
<span class="sd">        {(0, 1): 0.8709, (1, 6): 1.234, ...}</span>

<span class="sd">        The keys are the atom indexes and the values are the Wiberg bond indexes</span>
<span class="sd">        that are printed using `pop=NBOREAD` and `$nbo bndidx $end`.</span>

<span class="sd">    Methods:</span>

<span class="sd">    .. method:: to_input()</span>

<span class="sd">        Return a GaussianInput object using the last geometry and the same</span>
<span class="sd">        calculation parameters.</span>

<span class="sd">    .. method:: read_scan()</span>

<span class="sd">        Read a potential energy surface from a gaussian scan calculation.</span>

<span class="sd">    .. method:: get_scan_plot()</span>

<span class="sd">        Get a matplotlib plot of the potential energy surface</span>

<span class="sd">    .. method:: save_scan_plot()</span>

<span class="sd">        Save a matplotlib plot of the potential energy surface to a file</span>

<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            filename: Filename of Gaussian output file.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">filename</span> <span class="o">=</span> <span class="n">filename</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_parse</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">final_energy</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :return: Final energy in Gaussian output.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">energies</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">final_structure</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :return: Final structure in Gaussian output.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">structures</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>

    <span class="k">def</span> <span class="nf">_parse</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="p">):</span>
        <span class="n">start_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot; \(Enter \S+l101\.exe\)&quot;</span><span class="p">)</span>
        <span class="n">route_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot; #[pPnNtT]*.*&quot;</span><span class="p">)</span>
        <span class="n">link0_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;^\s(%.+)\s*=\s*(.+)&quot;</span><span class="p">)</span>
        <span class="n">charge_mul_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;Charge\s+=\s*([-\d]+)\s+&quot;</span>
                                     <span class="sa">r</span><span class="s2">&quot;Multiplicity\s+=\s*(\d+)&quot;</span><span class="p">)</span>
        <span class="n">num_basis_func_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;([0-9]+)\s+basis functions&quot;</span><span class="p">)</span>
        <span class="n">num_elec_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;(\d+)\s+alpha electrons\s+(\d+)\s+beta electrons&quot;</span><span class="p">)</span>
        <span class="n">pcm_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;Polarizable Continuum Model&quot;</span><span class="p">)</span>
        <span class="n">stat_type_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;imaginary frequencies&quot;</span><span class="p">)</span>
        <span class="n">scf_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;E\(.*\)\s*=\s*([-\.\d]+)\s+&quot;</span><span class="p">)</span>
        <span class="n">mp2_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;EUMP2\s*=\s*(.*)&quot;</span><span class="p">)</span>
        <span class="n">oniom_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;ONIOM:\s+extrapolated energy\s*=\s*(.*)&quot;</span><span class="p">)</span>
        <span class="n">termination_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;(Normal|Error) termination&quot;</span><span class="p">)</span>
        <span class="n">error_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span>
            <span class="sa">r</span><span class="s2">&quot;(! Non-Optimized Parameters !|Convergence failure)&quot;</span><span class="p">)</span>
        <span class="n">mulliken_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span>
            <span class="sa">r</span><span class="s2">&quot;^\s*(Mulliken charges|Mulliken atomic charges)&quot;</span><span class="p">)</span>
        <span class="n">mulliken_charge_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span>
            <span class="sa">r</span><span class="s1">&#39;^\s+(\d+)\s+([A-Z][a-z]?)\s*(\S*)&#39;</span><span class="p">)</span>
        <span class="n">end_mulliken_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span>
            <span class="sa">r</span><span class="s1">&#39;(Sum of Mulliken )(.*)(charges)\s*=\s*(\D)&#39;</span><span class="p">)</span>
        <span class="n">std_orientation_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;Standard orientation&quot;</span><span class="p">)</span>
        <span class="n">input_orientation_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;Input orientation|Z-Matrix orientation&quot;</span><span class="p">)</span>
        <span class="n">orbital_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;(Alpha|Beta)\s*\S+\s*eigenvalues --(.*)&quot;</span><span class="p">)</span>
        <span class="n">thermo_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;(Zero-point|Thermal) correction(.*)=&quot;</span>
                                 <span class="sa">r</span><span class="s2">&quot;\s+([\d\.-]+)&quot;</span><span class="p">)</span>
        <span class="n">forces_on_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span>
            <span class="sa">r</span><span class="s2">&quot;Center\s+Atomic\s+Forces\s+\(Hartrees/Bohr\)&quot;</span><span class="p">)</span>
        <span class="n">forces_off_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;Cartesian\s+Forces:\s+Max.*RMS.*&quot;</span><span class="p">)</span>
        <span class="n">forces_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span>
            <span class="sa">r</span><span class="s2">&quot;\s+(\d+)\s+(\d+)\s+([0-9\.-]+)\s+([0-9\.-]+)\s+([0-9\.-]+)&quot;</span><span class="p">)</span>

        <span class="n">freq_on_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span>
            <span class="sa">r</span><span class="s2">&quot;Harmonic\sfrequencies\s+\(cm\*\*-1\),\sIR\sintensities.*Raman.*&quot;</span><span class="p">)</span>

        <span class="n">normal_mode_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span>
            <span class="sa">r</span><span class="s2">&quot;\s+(\d+)\s+(\d+)\s+([0-9\.-]{4,5})\s+([0-9\.-]{4,5}).*&quot;</span><span class="p">)</span>

        <span class="n">mo_coeff_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;Molecular Orbital Coefficients:&quot;</span><span class="p">)</span>
        <span class="n">mo_coeff_name_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;\d+\s((\d+|\s+)\s+([a-zA-Z]{1,2}|\s+))\s+(\d+\S+)&quot;</span><span class="p">)</span>

        <span class="n">hessian_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;Force constants in Cartesian coordinates:&quot;</span><span class="p">)</span>
        <span class="n">resume_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;^\s1</span><span class="se">\\</span><span class="s2">1</span><span class="se">\\</span><span class="s2">GINC-\S*&quot;</span><span class="p">)</span>
        <span class="n">resume_end_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;^\s.*</span><span class="se">\\\\</span><span class="s2">@&quot;</span><span class="p">)</span>

        <span class="n">bond_order_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;Wiberg bond index matrix in the NAO basis:&quot;</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">properly_terminated</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">is_pcm</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">stationary_type</span> <span class="o">=</span> <span class="s2">&quot;Minimum&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">corrections</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">energies</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">pcm</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">errors</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">Mulliken_charges</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">link0</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">cart_forces</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">frequencies</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">eigenvalues</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">is_spin</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">hessian</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">resumes</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">title</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">bond_orders</span> <span class="o">=</span> <span class="p">{}</span>

        <span class="n">read_coord</span> <span class="o">=</span> <span class="mi">0</span>
        <span class="n">read_mulliken</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="n">read_eigen</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="n">eigen_txt</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">parse_stage</span> <span class="o">=</span> <span class="mi">0</span>
        <span class="n">num_basis_found</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="n">terminated</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="n">parse_forces</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="n">forces</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">parse_freq</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="n">frequencies</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">read_mo</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="n">parse_hessian</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="n">routeline</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span>
        <span class="n">standard_orientation</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="n">parse_bond_order</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="n">input_structures</span> <span class="o">=</span> <span class="nb">list</span><span class="p">()</span>
        <span class="n">std_structures</span> <span class="o">=</span> <span class="nb">list</span><span class="p">()</span>
        <span class="n">geom_orientation</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="n">opt_structures</span> <span class="o">=</span> <span class="nb">list</span><span class="p">()</span>

        <span class="k">with</span> <span class="n">zopen</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">f</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">parse_stage</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                    <span class="k">if</span> <span class="n">start_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
                        <span class="n">parse_stage</span> <span class="o">=</span> <span class="mi">1</span>
                    <span class="k">elif</span> <span class="n">link0_patt</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
                        <span class="n">m</span> <span class="o">=</span> <span class="n">link0_patt</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">link0</span><span class="p">[</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">)]</span> <span class="o">=</span> <span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
                    <span class="k">elif</span> <span class="n">route_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">)</span> <span class="ow">or</span> <span class="n">routeline</span> <span class="o">!=</span> <span class="s2">&quot;&quot;</span><span class="p">:</span>
                        <span class="k">if</span> <span class="nb">set</span><span class="p">(</span><span class="n">line</span><span class="o">.</span><span class="n">strip</span><span class="p">())</span> <span class="o">==</span> <span class="p">{</span><span class="s2">&quot;-&quot;</span><span class="p">}:</span>
                            <span class="n">params</span> <span class="o">=</span> <span class="n">read_route_line</span><span class="p">(</span><span class="n">routeline</span><span class="p">)</span>
                            <span class="bp">self</span><span class="o">.</span><span class="n">functional</span> <span class="o">=</span> <span class="n">params</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
                            <span class="bp">self</span><span class="o">.</span><span class="n">basis_set</span> <span class="o">=</span> <span class="n">params</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
                            <span class="bp">self</span><span class="o">.</span><span class="n">route_parameters</span> <span class="o">=</span> <span class="n">params</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span>
                            <span class="n">route_lower</span> <span class="o">=</span> <span class="p">{</span><span class="n">k</span><span class="o">.</span><span class="n">lower</span><span class="p">():</span> <span class="n">v</span>
                                           <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span>
                                           <span class="bp">self</span><span class="o">.</span><span class="n">route_parameters</span><span class="o">.</span><span class="n">items</span><span class="p">()}</span>
                            <span class="bp">self</span><span class="o">.</span><span class="n">dieze_tag</span> <span class="o">=</span> <span class="n">params</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span>
                            <span class="n">parse_stage</span> <span class="o">=</span> <span class="mi">1</span>
                        <span class="k">else</span><span class="p">:</span>
                            <span class="n">routeline</span> <span class="o">+=</span> <span class="n">line</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
                <span class="k">elif</span> <span class="n">parse_stage</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
                    <span class="k">if</span> <span class="nb">set</span><span class="p">(</span><span class="n">line</span><span class="o">.</span><span class="n">strip</span><span class="p">())</span> <span class="o">==</span> <span class="p">{</span><span class="s2">&quot;-&quot;</span><span class="p">}</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">title</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">title</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span>
                    <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">title</span> <span class="o">==</span> <span class="s2">&quot;&quot;</span><span class="p">:</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">title</span> <span class="o">=</span> <span class="n">line</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
                    <span class="k">elif</span> <span class="n">charge_mul_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
                        <span class="n">m</span> <span class="o">=</span> <span class="n">charge_mul_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">charge</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">))</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">spin_multiplicity</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">2</span><span class="p">))</span>
                        <span class="n">parse_stage</span> <span class="o">=</span> <span class="mi">2</span>
                <span class="k">elif</span> <span class="n">parse_stage</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span>

                    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_pcm</span><span class="p">:</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">_check_pcm</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>

                    <span class="k">if</span> <span class="s2">&quot;freq&quot;</span> <span class="ow">in</span> <span class="n">route_lower</span> <span class="ow">and</span> <span class="n">thermo_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
                        <span class="n">m</span> <span class="o">=</span> <span class="n">thermo_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
                        <span class="k">if</span> <span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="o">==</span> <span class="s2">&quot;Zero-point&quot;</span><span class="p">:</span>
                            <span class="bp">self</span><span class="o">.</span><span class="n">corrections</span><span class="p">[</span><span class="s2">&quot;Zero-point&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">3</span><span class="p">))</span>
                        <span class="k">else</span><span class="p">:</span>
                            <span class="n">key</span> <span class="o">=</span> <span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">(</span><span class="s2">&quot; to &quot;</span><span class="p">)</span>
                            <span class="bp">self</span><span class="o">.</span><span class="n">corrections</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">3</span><span class="p">))</span>

                    <span class="k">if</span> <span class="n">read_coord</span><span class="p">:</span>
                        <span class="p">[</span><span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">3</span><span class="p">)]</span>
                        <span class="n">line</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
                        <span class="n">sp</span> <span class="o">=</span> <span class="p">[]</span>
                        <span class="n">coords</span> <span class="o">=</span> <span class="p">[]</span>
                        <span class="k">while</span> <span class="nb">set</span><span class="p">(</span><span class="n">line</span><span class="o">.</span><span class="n">strip</span><span class="p">())</span> <span class="o">!=</span> <span class="p">{</span><span class="s2">&quot;-&quot;</span><span class="p">}:</span>
                            <span class="n">toks</span> <span class="o">=</span> <span class="n">line</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
                            <span class="n">sp</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">Element</span><span class="o">.</span><span class="n">from_Z</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">toks</span><span class="p">[</span><span class="mi">1</span><span class="p">])))</span>
                            <span class="n">coords</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="nb">float</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">toks</span><span class="p">[</span><span class="mi">3</span><span class="p">:</span><span class="mi">6</span><span class="p">]])</span>
                            <span class="n">line</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>

                        <span class="n">read_coord</span> <span class="o">=</span> <span class="kc">False</span>
                        <span class="k">if</span> <span class="n">geom_orientation</span> <span class="o">==</span> <span class="s2">&quot;input&quot;</span><span class="p">:</span>
                            <span class="n">input_structures</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">Molecule</span><span class="p">(</span><span class="n">sp</span><span class="p">,</span> <span class="n">coords</span><span class="p">))</span>
                        <span class="k">elif</span> <span class="n">geom_orientation</span> <span class="o">==</span> <span class="s2">&quot;standard&quot;</span><span class="p">:</span>
                            <span class="n">std_structures</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">Molecule</span><span class="p">(</span><span class="n">sp</span><span class="p">,</span> <span class="n">coords</span><span class="p">))</span>

                    <span class="k">if</span> <span class="n">parse_forces</span><span class="p">:</span>
                        <span class="n">m</span> <span class="o">=</span> <span class="n">forces_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
                        <span class="k">if</span> <span class="n">m</span><span class="p">:</span>
                            <span class="n">forces</span><span class="o">.</span><span class="n">extend</span><span class="p">([</span><span class="nb">float</span><span class="p">(</span><span class="n">_v</span><span class="p">)</span>
                                           <span class="k">for</span> <span class="n">_v</span> <span class="ow">in</span> <span class="n">m</span><span class="o">.</span><span class="n">groups</span><span class="p">()[</span><span class="mi">2</span><span class="p">:</span><span class="mi">5</span><span class="p">]])</span>
                        <span class="k">elif</span> <span class="n">forces_off_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
                            <span class="bp">self</span><span class="o">.</span><span class="n">cart_forces</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">forces</span><span class="p">)</span>
                            <span class="n">forces</span> <span class="o">=</span> <span class="p">[]</span>
                            <span class="n">parse_forces</span> <span class="o">=</span> <span class="kc">False</span>

                    <span class="c1"># read molecular orbital eigenvalues</span>
                    <span class="k">if</span> <span class="n">read_eigen</span><span class="p">:</span>
                        <span class="n">m</span> <span class="o">=</span> <span class="n">orbital_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
                        <span class="k">if</span> <span class="n">m</span><span class="p">:</span>
                            <span class="n">eigen_txt</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
                        <span class="k">else</span><span class="p">:</span>
                            <span class="n">read_eigen</span> <span class="o">=</span> <span class="kc">False</span>
                            <span class="bp">self</span><span class="o">.</span><span class="n">eigenvalues</span> <span class="o">=</span> <span class="p">{</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">:</span> <span class="p">[]}</span>
                            <span class="k">for</span> <span class="n">eigenline</span> <span class="ow">in</span> <span class="n">eigen_txt</span><span class="p">:</span>
                                <span class="k">if</span> <span class="s2">&quot;Alpha&quot;</span> <span class="ow">in</span> <span class="n">eigenline</span><span class="p">:</span>
                                    <span class="bp">self</span><span class="o">.</span><span class="n">eigenvalues</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">]</span> <span class="o">+=</span> <span class="p">[</span><span class="nb">float</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">float_patt</span><span class="o">.</span><span class="n">findall</span><span class="p">(</span><span class="n">eigenline</span><span class="p">)]</span>
                                <span class="k">elif</span> <span class="s2">&quot;Beta&quot;</span> <span class="ow">in</span> <span class="n">eigenline</span><span class="p">:</span>
                                    <span class="k">if</span> <span class="n">Spin</span><span class="o">.</span><span class="n">down</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">eigenvalues</span><span class="p">:</span>
                                        <span class="bp">self</span><span class="o">.</span><span class="n">eigenvalues</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
                                    <span class="bp">self</span><span class="o">.</span><span class="n">eigenvalues</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">]</span> <span class="o">+=</span> <span class="p">[</span><span class="nb">float</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">float_patt</span><span class="o">.</span><span class="n">findall</span><span class="p">(</span><span class="n">eigenline</span><span class="p">)]</span>
                            <span class="n">eigen_txt</span> <span class="o">=</span> <span class="p">[]</span>

                    <span class="c1"># read molecular orbital coefficients</span>
                    <span class="k">if</span> <span class="p">(</span><span class="ow">not</span> <span class="n">num_basis_found</span><span class="p">)</span> <span class="ow">and</span> <span class="n">num_basis_func_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
                        <span class="n">m</span> <span class="o">=</span> <span class="n">num_basis_func_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">num_basis_func</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">))</span>
                        <span class="n">num_basis_found</span> <span class="o">=</span> <span class="kc">True</span>
                    <span class="k">elif</span> <span class="n">read_mo</span><span class="p">:</span>
                        <span class="c1"># build a matrix with all coefficients</span>
                        <span class="n">all_spin</span> <span class="o">=</span> <span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">]</span>
                        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_spin</span><span class="p">:</span>
                            <span class="n">all_spin</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">)</span>

                        <span class="n">mat_mo</span> <span class="o">=</span> <span class="p">{}</span>
                        <span class="k">for</span> <span class="n">spin</span> <span class="ow">in</span> <span class="n">all_spin</span><span class="p">:</span>
                            <span class="n">mat_mo</span><span class="p">[</span><span class="n">spin</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="bp">self</span><span class="o">.</span><span class="n">num_basis_func</span><span class="p">,</span>
                                                     <span class="bp">self</span><span class="o">.</span><span class="n">num_basis_func</span><span class="p">))</span>
                            <span class="n">nMO</span> <span class="o">=</span> <span class="mi">0</span>
                            <span class="n">end_mo</span> <span class="o">=</span> <span class="kc">False</span>
                            <span class="k">while</span> <span class="n">nMO</span> <span class="o">&lt;</span> <span class="bp">self</span><span class="o">.</span><span class="n">num_basis_func</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">end_mo</span><span class="p">:</span>
                                <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
                                <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
                                <span class="bp">self</span><span class="o">.</span><span class="n">atom_basis_labels</span> <span class="o">=</span> <span class="p">[]</span>
                                <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">num_basis_func</span><span class="p">):</span>
                                    <span class="n">line</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>

                                    <span class="c1"># identify atom and OA labels</span>
                                    <span class="n">m</span> <span class="o">=</span> <span class="n">mo_coeff_name_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
                                    <span class="k">if</span> <span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="o">!=</span> <span class="s2">&quot;&quot;</span><span class="p">:</span>
                                        <span class="n">iat</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">2</span><span class="p">))</span> <span class="o">-</span> <span class="mi">1</span>
                                        <span class="c1"># atname = m.group(3)</span>
                                        <span class="bp">self</span><span class="o">.</span><span class="n">atom_basis_labels</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">4</span><span class="p">)])</span>
                                    <span class="k">else</span><span class="p">:</span>
                                        <span class="bp">self</span><span class="o">.</span><span class="n">atom_basis_labels</span><span class="p">[</span><span class="n">iat</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">4</span><span class="p">))</span>

                                    <span class="c1"># MO coefficients</span>
                                    <span class="n">coeffs</span> <span class="o">=</span> <span class="p">[</span><span class="nb">float</span><span class="p">(</span><span class="n">c</span><span class="p">)</span> <span class="k">for</span> <span class="n">c</span> <span class="ow">in</span>
                                              <span class="n">float_patt</span><span class="o">.</span><span class="n">findall</span><span class="p">(</span><span class="n">line</span><span class="p">)]</span>
                                    <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">coeffs</span><span class="p">)):</span>
                                        <span class="n">mat_mo</span><span class="p">[</span><span class="n">spin</span><span class="p">][</span><span class="n">i</span><span class="p">,</span> <span class="n">nMO</span> <span class="o">+</span> <span class="n">j</span><span class="p">]</span> <span class="o">=</span> <span class="n">coeffs</span><span class="p">[</span><span class="n">j</span><span class="p">]</span>

                                <span class="n">nMO</span> <span class="o">+=</span> <span class="nb">len</span><span class="p">(</span><span class="n">coeffs</span><span class="p">)</span>
                                <span class="n">line</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
                                <span class="c1"># manage pop=regular case (not all MO)</span>
                                <span class="k">if</span> <span class="n">nMO</span> <span class="o">&lt;</span> <span class="bp">self</span><span class="o">.</span><span class="n">num_basis_func</span> <span class="ow">and</span> \
                                    <span class="p">(</span><span class="s2">&quot;Density Matrix:&quot;</span> <span class="ow">in</span> <span class="n">line</span> <span class="ow">or</span>
                                     <span class="n">mo_coeff_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">)):</span>
                                    <span class="n">end_mo</span> <span class="o">=</span> <span class="kc">True</span>
                                    <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="s2">&quot;POP=regular case, matrix &quot;</span>
                                                  <span class="s2">&quot;coefficients not complete&quot;</span><span class="p">)</span>
                            <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>

                        <span class="bp">self</span><span class="o">.</span><span class="n">eigenvectors</span> <span class="o">=</span> <span class="n">mat_mo</span>
                        <span class="n">read_mo</span> <span class="o">=</span> <span class="kc">False</span>

                        <span class="c1"># build a more convenient array dict with MO</span>
                        <span class="c1"># coefficient of each atom in each MO.</span>
                        <span class="c1"># mo[Spin][OM j][atom i] =</span>
                        <span class="c1"># {AO_k: coeff, AO_k: coeff ... }</span>
                        <span class="n">mo</span> <span class="o">=</span> <span class="p">{}</span>
                        <span class="k">for</span> <span class="n">spin</span> <span class="ow">in</span> <span class="n">all_spin</span><span class="p">:</span>
                            <span class="n">mo</span><span class="p">[</span><span class="n">spin</span><span class="p">]</span> <span class="o">=</span> <span class="p">[[{}</span> <span class="k">for</span> <span class="n">iat</span> <span class="ow">in</span>
                                         <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">atom_basis_labels</span><span class="p">))]</span>
                                        <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">num_basis_func</span><span class="p">)]</span>
                            <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">num_basis_func</span><span class="p">):</span>
                                <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span>
                                <span class="k">for</span> <span class="n">iat</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">atom_basis_labels</span><span class="p">)):</span>
                                    <span class="k">for</span> <span class="n">label</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">atom_basis_labels</span><span class="p">[</span><span class="n">iat</span><span class="p">]:</span>
                                        <span class="n">mo</span><span class="p">[</span><span class="n">spin</span><span class="p">][</span><span class="n">j</span><span class="p">][</span><span class="n">iat</span><span class="p">][</span><span class="n">label</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">eigenvectors</span><span class="p">[</span><span class="n">spin</span><span class="p">][</span><span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">]</span>
                                        <span class="n">i</span> <span class="o">+=</span> <span class="mi">1</span>

                        <span class="bp">self</span><span class="o">.</span><span class="n">molecular_orbital</span> <span class="o">=</span> <span class="n">mo</span>

                    <span class="k">elif</span> <span class="n">parse_freq</span><span class="p">:</span>
                        <span class="k">while</span> <span class="n">line</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="o">!=</span> <span class="s2">&quot;&quot;</span><span class="p">:</span>  <span class="c1">#  blank line</span>
                            <span class="n">ifreqs</span> <span class="o">=</span> <span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">val</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span> <span class="k">for</span> <span class="n">val</span> <span class="ow">in</span> <span class="n">line</span><span class="o">.</span><span class="n">split</span><span class="p">()]</span>
                            <span class="k">for</span> <span class="n">ifreq</span> <span class="ow">in</span> <span class="n">ifreqs</span><span class="p">:</span>
                                <span class="n">frequencies</span><span class="o">.</span><span class="n">append</span><span class="p">({</span><span class="s2">&quot;frequency&quot;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                                                    <span class="s2">&quot;r_mass&quot;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                                                    <span class="s2">&quot;f_constant&quot;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                                                    <span class="s2">&quot;IR_intensity&quot;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                                                    <span class="s2">&quot;symmetry&quot;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                                                    <span class="s2">&quot;mode&quot;</span><span class="p">:</span> <span class="p">[]})</span>
                            <span class="c1"># read freq, intensity, masses, symmetry ...</span>
                            <span class="k">while</span> <span class="s2">&quot;Atom  AN&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">line</span><span class="p">:</span>
                                <span class="k">if</span> <span class="s2">&quot;Frequencies --&quot;</span> <span class="ow">in</span> <span class="n">line</span><span class="p">:</span>
                                    <span class="n">freqs</span> <span class="o">=</span> <span class="nb">map</span><span class="p">(</span><span class="nb">float</span><span class="p">,</span>
                                                <span class="n">float_patt</span><span class="o">.</span><span class="n">findall</span><span class="p">(</span><span class="n">line</span><span class="p">))</span>
                                    <span class="k">for</span> <span class="n">ifreq</span><span class="p">,</span> <span class="n">freq</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">ifreqs</span><span class="p">,</span> <span class="n">freqs</span><span class="p">):</span>
                                        <span class="n">frequencies</span><span class="p">[</span><span class="n">ifreq</span><span class="p">][</span><span class="s2">&quot;frequency&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">freq</span>
                                <span class="k">elif</span> <span class="s2">&quot;Red. masses --&quot;</span> <span class="ow">in</span> <span class="n">line</span><span class="p">:</span>
                                    <span class="n">r_masses</span> <span class="o">=</span> <span class="nb">map</span><span class="p">(</span><span class="nb">float</span><span class="p">,</span>
                                                   <span class="n">float_patt</span><span class="o">.</span><span class="n">findall</span><span class="p">(</span><span class="n">line</span><span class="p">))</span>
                                    <span class="k">for</span> <span class="n">ifreq</span><span class="p">,</span> <span class="n">r_mass</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">ifreqs</span><span class="p">,</span> <span class="n">r_masses</span><span class="p">):</span>
                                        <span class="n">frequencies</span><span class="p">[</span><span class="n">ifreq</span><span class="p">][</span><span class="s2">&quot;r_mass&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">r_mass</span>
                                <span class="k">elif</span> <span class="s2">&quot;Frc consts  --&quot;</span> <span class="ow">in</span> <span class="n">line</span><span class="p">:</span>
                                    <span class="n">f_consts</span> <span class="o">=</span> <span class="nb">map</span><span class="p">(</span><span class="nb">float</span><span class="p">,</span>
                                                   <span class="n">float_patt</span><span class="o">.</span><span class="n">findall</span><span class="p">(</span><span class="n">line</span><span class="p">))</span>
                                    <span class="k">for</span> <span class="n">ifreq</span><span class="p">,</span> <span class="n">f_const</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">ifreqs</span><span class="p">,</span> <span class="n">f_consts</span><span class="p">):</span>
                                        <span class="n">frequencies</span><span class="p">[</span><span class="n">ifreq</span><span class="p">][</span><span class="s2">&quot;f_constant&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">f_const</span>
                                <span class="k">elif</span> <span class="s2">&quot;IR Inten    --&quot;</span> <span class="ow">in</span> <span class="n">line</span><span class="p">:</span>
                                    <span class="n">IR_intens</span> <span class="o">=</span> <span class="nb">map</span><span class="p">(</span><span class="nb">float</span><span class="p">,</span>
                                                    <span class="n">float_patt</span><span class="o">.</span><span class="n">findall</span><span class="p">(</span><span class="n">line</span><span class="p">))</span>
                                    <span class="k">for</span> <span class="n">ifreq</span><span class="p">,</span> <span class="n">intens</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">ifreqs</span><span class="p">,</span> <span class="n">IR_intens</span><span class="p">):</span>
                                        <span class="n">frequencies</span><span class="p">[</span><span class="n">ifreq</span><span class="p">][</span><span class="s2">&quot;IR_intensity&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">intens</span>
                                <span class="k">else</span><span class="p">:</span>
                                    <span class="n">syms</span> <span class="o">=</span> <span class="n">line</span><span class="o">.</span><span class="n">split</span><span class="p">()[:</span><span class="mi">3</span><span class="p">]</span>
                                    <span class="k">for</span> <span class="n">ifreq</span><span class="p">,</span> <span class="n">sym</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">ifreqs</span><span class="p">,</span> <span class="n">syms</span><span class="p">):</span>
                                        <span class="n">frequencies</span><span class="p">[</span><span class="n">ifreq</span><span class="p">][</span><span class="s2">&quot;symmetry&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">sym</span>
                                <span class="n">line</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>

                            <span class="c1">#  read normal modes</span>
                            <span class="n">line</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
                            <span class="k">while</span> <span class="n">normal_mode_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
                                <span class="n">values</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">map</span><span class="p">(</span><span class="nb">float</span><span class="p">,</span>
                                                  <span class="n">float_patt</span><span class="o">.</span><span class="n">findall</span><span class="p">(</span><span class="n">line</span><span class="p">)))</span>
                                <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">ifreq</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">values</span><span class="p">),</span> <span class="mi">3</span><span class="p">),</span>
                                                    <span class="n">ifreqs</span><span class="p">):</span>
                                    <span class="n">frequencies</span><span class="p">[</span><span class="n">ifreq</span><span class="p">][</span><span class="s2">&quot;mode&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">values</span><span class="p">[</span><span class="n">i</span><span class="p">:</span><span class="n">i</span><span class="o">+</span><span class="mi">3</span><span class="p">])</span>
                                <span class="n">line</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>

                        <span class="n">parse_freq</span> <span class="o">=</span> <span class="kc">False</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">frequencies</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">frequencies</span><span class="p">)</span>
                        <span class="n">frequencies</span> <span class="o">=</span> <span class="p">[]</span>

                    <span class="k">elif</span> <span class="n">parse_hessian</span><span class="p">:</span>
                        <span class="c1">#  read Hessian matrix under &quot;Force constants in Cartesian coordinates&quot;</span>
                        <span class="c1">#  Hessian matrix is in the input  orientation framework</span>
                        <span class="c1"># WARNING : need #P in the route line</span>
                        <span class="n">parse_hessian</span> <span class="o">=</span> <span class="kc">False</span>
                        <span class="n">ndf</span> <span class="o">=</span> <span class="mi">3</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">input_structures</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">hessian</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="n">ndf</span><span class="p">,</span> <span class="n">ndf</span><span class="p">))</span>
                        <span class="n">j_indices</span> <span class="o">=</span> <span class="nb">range</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span>
                        <span class="n">jndf</span> <span class="o">=</span> <span class="mi">0</span>
                        <span class="k">while</span> <span class="n">jndf</span> <span class="o">&lt;</span> <span class="n">ndf</span><span class="p">:</span>
                            <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">jndf</span><span class="p">,</span> <span class="n">ndf</span><span class="p">):</span>
                                <span class="n">line</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
                                <span class="n">vals</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">findall</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;\s*([+-]?\d+\.\d+[eEdD]?[+-]\d+)&quot;</span><span class="p">,</span> <span class="n">line</span><span class="p">)</span>
                                <span class="n">vals</span> <span class="o">=</span> <span class="p">[</span><span class="nb">float</span><span class="p">(</span><span class="n">val</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot;D&quot;</span><span class="p">,</span> <span class="s2">&quot;E&quot;</span><span class="p">))</span>
                                        <span class="k">for</span> <span class="n">val</span> <span class="ow">in</span> <span class="n">vals</span><span class="p">]</span>
                                <span class="k">for</span> <span class="n">jval</span><span class="p">,</span> <span class="n">val</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">vals</span><span class="p">):</span>
                                    <span class="n">j</span> <span class="o">=</span> <span class="n">j_indices</span><span class="p">[</span><span class="n">jval</span><span class="p">]</span>
                                    <span class="bp">self</span><span class="o">.</span><span class="n">hessian</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">]</span> <span class="o">=</span> <span class="n">val</span>
                                    <span class="bp">self</span><span class="o">.</span><span class="n">hessian</span><span class="p">[</span><span class="n">j</span><span class="p">,</span> <span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">val</span>
                            <span class="n">jndf</span> <span class="o">+=</span> <span class="nb">len</span><span class="p">(</span><span class="n">vals</span><span class="p">)</span>
                            <span class="n">line</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
                            <span class="n">j_indices</span> <span class="o">=</span> <span class="p">[</span><span class="n">j</span> <span class="o">+</span> <span class="mi">5</span> <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="n">j_indices</span><span class="p">]</span>

                    <span class="k">elif</span> <span class="n">parse_bond_order</span><span class="p">:</span>
                        <span class="c1"># parse Wiberg bond order</span>
                        <span class="n">line</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
                        <span class="n">line</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
                        <span class="n">nat</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">input_structures</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
                        <span class="n">matrix</span> <span class="o">=</span> <span class="nb">list</span><span class="p">()</span>
                        <span class="k">for</span> <span class="n">iat</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">nat</span><span class="p">):</span>
                            <span class="n">line</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
                            <span class="n">matrix</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="nb">float</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">line</span><span class="o">.</span><span class="n">split</span><span class="p">()[</span><span class="mi">2</span><span class="p">:]])</span>

                        <span class="bp">self</span><span class="o">.</span><span class="n">bond_orders</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">()</span>
                        <span class="k">for</span> <span class="n">iat</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">nat</span><span class="p">):</span>
                            <span class="k">for</span> <span class="n">jat</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">iat</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">nat</span><span class="p">):</span>
                                <span class="bp">self</span><span class="o">.</span><span class="n">bond_orders</span><span class="p">[(</span><span class="n">iat</span><span class="p">,</span> <span class="n">jat</span><span class="p">)]</span> <span class="o">=</span> <span class="n">matrix</span><span class="p">[</span><span class="n">iat</span><span class="p">][</span><span class="n">jat</span><span class="p">]</span>
                        <span class="n">parse_bond_order</span> <span class="o">=</span> <span class="kc">False</span>

                    <span class="k">elif</span> <span class="n">termination_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
                        <span class="n">m</span> <span class="o">=</span> <span class="n">termination_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
                        <span class="k">if</span> <span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="o">==</span> <span class="s2">&quot;Normal&quot;</span><span class="p">:</span>
                            <span class="bp">self</span><span class="o">.</span><span class="n">properly_terminated</span> <span class="o">=</span> <span class="kc">True</span>
                            <span class="n">terminated</span> <span class="o">=</span> <span class="kc">True</span>
                    <span class="k">elif</span> <span class="n">error_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
                        <span class="n">error_defs</span> <span class="o">=</span> <span class="p">{</span>
                            <span class="s2">&quot;! Non-Optimized Parameters !&quot;</span><span class="p">:</span> <span class="s2">&quot;Optimization &quot;</span>
                                                            <span class="s2">&quot;error&quot;</span><span class="p">,</span>
                            <span class="s2">&quot;Convergence failure&quot;</span><span class="p">:</span> <span class="s2">&quot;SCF convergence error&quot;</span>
                        <span class="p">}</span>
                        <span class="n">m</span> <span class="o">=</span> <span class="n">error_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">errors</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">error_defs</span><span class="p">[</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">)])</span>
                    <span class="k">elif</span> <span class="n">num_elec_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
                        <span class="n">m</span> <span class="o">=</span> <span class="n">num_elec_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">electrons</span> <span class="o">=</span> <span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">)),</span> <span class="nb">int</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">2</span><span class="p">)))</span>
                    <span class="k">elif</span> <span class="p">(</span><span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_pcm</span><span class="p">)</span> <span class="ow">and</span> <span class="n">pcm_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">is_pcm</span> <span class="o">=</span> <span class="kc">True</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">pcm</span> <span class="o">=</span> <span class="p">{}</span>
                    <span class="k">elif</span> <span class="s2">&quot;freq&quot;</span> <span class="ow">in</span> <span class="n">route_lower</span> <span class="ow">and</span> <span class="s2">&quot;opt&quot;</span> <span class="ow">in</span> <span class="n">route_lower</span> <span class="ow">and</span> \
                            <span class="n">stat_type_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">stationary_type</span> <span class="o">=</span> <span class="s2">&quot;Saddle&quot;</span>
                    <span class="k">elif</span> <span class="n">mp2_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
                        <span class="n">m</span> <span class="o">=</span> <span class="n">mp2_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">energies</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">float</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot;D&quot;</span><span class="p">,</span>
                                                                      <span class="s2">&quot;E&quot;</span><span class="p">)))</span>
                    <span class="k">elif</span> <span class="n">oniom_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
                        <span class="n">m</span> <span class="o">=</span> <span class="n">oniom_patt</span><span class="o">.</span><span class="n">matcher</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">energies</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">float</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">)))</span>
                    <span class="k">elif</span> <span class="n">scf_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
                        <span class="n">m</span> <span class="o">=</span> <span class="n">scf_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">energies</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">float</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">)))</span>
                    <span class="k">elif</span> <span class="n">std_orientation_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
                        <span class="n">standard_orientation</span> <span class="o">=</span> <span class="kc">True</span>
                        <span class="n">geom_orientation</span> <span class="o">=</span> <span class="s2">&quot;standard&quot;</span>
                        <span class="n">read_coord</span> <span class="o">=</span> <span class="kc">True</span>
                    <span class="k">elif</span> <span class="n">input_orientation_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
                        <span class="n">geom_orientation</span> <span class="o">=</span> <span class="s2">&quot;input&quot;</span>
                        <span class="n">read_coord</span> <span class="o">=</span> <span class="kc">True</span>
                    <span class="k">elif</span> <span class="s2">&quot;Optimization completed.&quot;</span> <span class="ow">in</span> <span class="n">line</span><span class="p">:</span>
                        <span class="n">line</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
                        <span class="k">if</span> <span class="s2">&quot; -- Stationary point found.&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">line</span><span class="p">:</span>
                            <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">filename</span> <span class="o">+</span>
                                          <span class="s2">&quot;: Optimization complete but this is not a stationary point&quot;</span><span class="p">)</span>
                        <span class="n">opt_structures</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">input_structures</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span>
                    <span class="k">elif</span> <span class="ow">not</span> <span class="n">read_eigen</span> <span class="ow">and</span> <span class="n">orbital_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
                        <span class="n">eigen_txt</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
                        <span class="n">read_eigen</span> <span class="o">=</span> <span class="kc">True</span>
                    <span class="k">elif</span> <span class="n">mulliken_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
                        <span class="n">mulliken_txt</span> <span class="o">=</span> <span class="p">[]</span>
                        <span class="n">read_mulliken</span> <span class="o">=</span> <span class="kc">True</span>
                    <span class="k">elif</span> <span class="ow">not</span> <span class="n">parse_forces</span> <span class="ow">and</span> <span class="n">forces_on_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
                        <span class="n">parse_forces</span> <span class="o">=</span> <span class="kc">True</span>
                    <span class="k">elif</span> <span class="n">freq_on_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
                        <span class="n">parse_freq</span> <span class="o">=</span> <span class="kc">True</span>
                        <span class="p">[</span><span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">3</span><span class="p">)]</span>
                    <span class="k">elif</span> <span class="n">mo_coeff_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
                        <span class="k">if</span> <span class="s2">&quot;Alpha&quot;</span> <span class="ow">in</span> <span class="n">line</span><span class="p">:</span>
                            <span class="bp">self</span><span class="o">.</span><span class="n">is_spin</span> <span class="o">=</span> <span class="kc">True</span>
                        <span class="n">read_mo</span> <span class="o">=</span> <span class="kc">True</span>
                    <span class="k">elif</span> <span class="n">hessian_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
                        <span class="n">parse_hessian</span> <span class="o">=</span> <span class="kc">True</span>
                    <span class="k">elif</span> <span class="n">resume_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
                        <span class="n">resume</span> <span class="o">=</span> <span class="p">[]</span>
                        <span class="k">while</span> <span class="ow">not</span> <span class="n">resume_end_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
                            <span class="n">resume</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
                            <span class="n">line</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
                            <span class="c1">#  security if \\@ not in one line !</span>
                            <span class="k">if</span> <span class="n">line</span> <span class="o">==</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">:</span>
                                <span class="k">break</span>
                        <span class="n">resume</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
                        <span class="n">resume</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="o">.</span><span class="n">join</span><span class="p">([</span><span class="n">r</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="k">for</span> <span class="n">r</span> <span class="ow">in</span> <span class="n">resume</span><span class="p">])</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">resumes</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">resume</span><span class="p">)</span>
                    <span class="k">elif</span> <span class="n">bond_order_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
                        <span class="n">parse_bond_order</span> <span class="o">=</span> <span class="kc">True</span>

                    <span class="k">if</span> <span class="n">read_mulliken</span><span class="p">:</span>
                        <span class="k">if</span> <span class="ow">not</span> <span class="n">end_mulliken_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
                            <span class="n">mulliken_txt</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
                        <span class="k">else</span><span class="p">:</span>
                            <span class="n">m</span> <span class="o">=</span> <span class="n">end_mulliken_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
                            <span class="n">mulliken_charges</span> <span class="o">=</span> <span class="p">{}</span>
                            <span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">mulliken_txt</span><span class="p">:</span>
                                <span class="k">if</span> <span class="n">mulliken_charge_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
                                    <span class="n">m</span> <span class="o">=</span> <span class="n">mulliken_charge_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
                                    <span class="n">dic</span> <span class="o">=</span> <span class="p">{</span><span class="nb">int</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">)):</span>
                                           <span class="p">[</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="nb">float</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">3</span><span class="p">))]}</span>
                                    <span class="n">mulliken_charges</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">dic</span><span class="p">)</span>
                            <span class="n">read_mulliken</span> <span class="o">=</span> <span class="kc">False</span>
                            <span class="bp">self</span><span class="o">.</span><span class="n">Mulliken_charges</span> <span class="o">=</span> <span class="n">mulliken_charges</span>

        <span class="c1"># store the structures. If symmetry is considered, the standard orientation</span>
        <span class="c1"># is used. Else the input orientation is used.</span>
        <span class="k">if</span> <span class="n">standard_orientation</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">structures</span> <span class="o">=</span> <span class="n">std_structures</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">structures_input_orientation</span> <span class="o">=</span> <span class="n">input_structures</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">structures</span> <span class="o">=</span> <span class="n">input_structures</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">structures_input_orientation</span> <span class="o">=</span> <span class="n">input_structures</span>
        <span class="c1"># store optimized structure in input orientation </span>
        <span class="bp">self</span><span class="o">.</span><span class="n">opt_structures</span> <span class="o">=</span> <span class="n">opt_structures</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="n">terminated</span><span class="p">:</span>
            <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">filename</span> <span class="o">+</span>
                          <span class="s2">&quot;: Termination error or bad Gaussian output file !&quot;</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_check_pcm</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">line</span><span class="p">):</span>
        <span class="n">energy_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;(Dispersion|Cavitation|Repulsion) energy&quot;</span>
                                 <span class="sa">r</span><span class="s2">&quot;\s+\S+\s+=\s+(\S*)&quot;</span><span class="p">)</span>
        <span class="n">total_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;with all non electrostatic terms\s+\S+\s+&quot;</span>
                                <span class="sa">r</span><span class="s2">&quot;=\s+(\S*)&quot;</span><span class="p">)</span>
        <span class="n">parameter_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;(Eps|Numeral density|RSolv|Eps&quot;</span>
                                    <span class="sa">r</span><span class="s2">&quot;\(inf[inity]*\))\s+=\s*(\S*)&quot;</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">energy_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
            <span class="n">m</span> <span class="o">=</span> <span class="n">energy_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">pcm</span><span class="p">[</span><span class="s1">&#39;</span><span class="si">{}</span><span class="s1"> energy&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">))]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">2</span><span class="p">))</span>
        <span class="k">elif</span> <span class="n">total_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
            <span class="n">m</span> <span class="o">=</span> <span class="n">total_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">pcm</span><span class="p">[</span><span class="s1">&#39;Total energy&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">))</span>
        <span class="k">elif</span> <span class="n">parameter_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
            <span class="n">m</span> <span class="o">=</span> <span class="n">parameter_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">pcm</span><span class="p">[</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">)]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">2</span><span class="p">))</span>

<div class="viewcode-block" id="GaussianOutput.as_dict"><a class="viewcode-back" href="../../../pymatgen.io.gaussian.html#pymatgen.io.gaussian.GaussianOutput.as_dict">[docs]</a>    <span class="k">def</span> <span class="nf">as_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Json-serializable dict representation.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">structure</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">final_structure</span>
        <span class="n">d</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;has_gaussian_completed&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">properly_terminated</span><span class="p">,</span>
             <span class="s2">&quot;nsites&quot;</span><span class="p">:</span> <span class="nb">len</span><span class="p">(</span><span class="n">structure</span><span class="p">)}</span>
        <span class="n">comp</span> <span class="o">=</span> <span class="n">structure</span><span class="o">.</span><span class="n">composition</span>
        <span class="n">d</span><span class="p">[</span><span class="s2">&quot;unit_cell_formula&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">comp</span><span class="o">.</span><span class="n">as_dict</span><span class="p">()</span>
        <span class="n">d</span><span class="p">[</span><span class="s2">&quot;reduced_cell_formula&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">Composition</span><span class="p">(</span><span class="n">comp</span><span class="o">.</span><span class="n">reduced_formula</span><span class="p">)</span><span class="o">.</span><span class="n">as_dict</span><span class="p">()</span>
        <span class="n">d</span><span class="p">[</span><span class="s2">&quot;pretty_formula&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">comp</span><span class="o">.</span><span class="n">reduced_formula</span>
        <span class="n">d</span><span class="p">[</span><span class="s2">&quot;is_pcm&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_pcm</span>
        <span class="n">d</span><span class="p">[</span><span class="s2">&quot;errors&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">errors</span>
        <span class="n">d</span><span class="p">[</span><span class="s2">&quot;Mulliken_charges&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">Mulliken_charges</span>

        <span class="n">unique_symbols</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="n">d</span><span class="p">[</span><span class="s2">&quot;unit_cell_formula&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">()))</span>
        <span class="n">d</span><span class="p">[</span><span class="s2">&quot;elements&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">unique_symbols</span>
        <span class="n">d</span><span class="p">[</span><span class="s2">&quot;nelements&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">unique_symbols</span><span class="p">)</span>
        <span class="n">d</span><span class="p">[</span><span class="s2">&quot;charge&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">charge</span>
        <span class="n">d</span><span class="p">[</span><span class="s2">&quot;spin_multiplicity&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">spin_multiplicity</span>

        <span class="n">vin</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;route&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">route_parameters</span><span class="p">,</span> <span class="s2">&quot;functional&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">functional</span><span class="p">,</span>
               <span class="s2">&quot;basis_set&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">basis_set</span><span class="p">,</span>
               <span class="s2">&quot;nbasisfunctions&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">num_basis_func</span><span class="p">,</span>
               <span class="s2">&quot;pcm_parameters&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">pcm</span><span class="p">}</span>

        <span class="n">d</span><span class="p">[</span><span class="s2">&quot;input&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">vin</span>

        <span class="n">nsites</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">final_structure</span><span class="p">)</span>

        <span class="n">vout</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s2">&quot;energies&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">energies</span><span class="p">,</span>
            <span class="s2">&quot;final_energy&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">final_energy</span><span class="p">,</span>
            <span class="s2">&quot;final_energy_per_atom&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">final_energy</span> <span class="o">/</span> <span class="n">nsites</span><span class="p">,</span>
            <span class="s2">&quot;molecule&quot;</span><span class="p">:</span> <span class="n">structure</span><span class="o">.</span><span class="n">as_dict</span><span class="p">(),</span>
            <span class="s2">&quot;stationary_type&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">stationary_type</span><span class="p">,</span>
            <span class="s2">&quot;corrections&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">corrections</span>
        <span class="p">}</span>

        <span class="n">d</span><span class="p">[</span><span class="s1">&#39;output&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">vout</span>
        <span class="n">d</span><span class="p">[</span><span class="s2">&quot;@module&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__module__</span>
        <span class="n">d</span><span class="p">[</span><span class="s2">&quot;@class&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span>

        <span class="k">return</span> <span class="n">d</span></div>

<div class="viewcode-block" id="GaussianOutput.read_scan"><a class="viewcode-back" href="../../../pymatgen.io.gaussian.html#pymatgen.io.gaussian.GaussianOutput.read_scan">[docs]</a>    <span class="k">def</span> <span class="nf">read_scan</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Read a potential energy surface from a gaussian scan calculation.</span>

<span class="sd">        Returns:</span>

<span class="sd">            A dict: {&quot;energies&quot;: [ values ],</span>
<span class="sd">                     &quot;coords&quot;: {&quot;d1&quot;: [ values ], &quot;A2&quot;, [ values ], ... }}</span>

<span class="sd">            &quot;energies&quot; are the energies of all points of the potential energy</span>
<span class="sd">            surface. &quot;coords&quot; are the internal coordinates used to compute the</span>
<span class="sd">            potential energy surface and the internal coordinates optimized,</span>
<span class="sd">            labelled by their name as defined in the calculation.</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">def</span> <span class="nf">floatList</span><span class="p">(</span><span class="n">l</span><span class="p">):</span>
            <span class="sd">&quot;&quot;&quot; return a list of float from a list of string &quot;&quot;&quot;</span>
            <span class="k">return</span> <span class="p">[</span><span class="nb">float</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">l</span><span class="p">]</span>

        <span class="n">scan_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;^\sSummary of the potential surface scan:&quot;</span><span class="p">)</span>
        <span class="n">optscan_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;^\sSummary of Optimized Potential Surface Scan&quot;</span><span class="p">)</span>
        <span class="n">coord_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;^\s*(\w+)((\s*[+-]?\d+\.\d+)+)&quot;</span><span class="p">)</span>

        <span class="c1"># data dict return</span>
        <span class="n">data</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;energies&quot;</span><span class="p">:</span> <span class="nb">list</span><span class="p">(),</span> <span class="s2">&quot;coords&quot;</span><span class="p">:</span> <span class="nb">dict</span><span class="p">()}</span>

        <span class="c1"># read in file</span>
        <span class="k">with</span> <span class="n">zopen</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">filename</span><span class="p">,</span> <span class="s2">&quot;r&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
            <span class="n">line</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>

            <span class="k">while</span> <span class="n">line</span> <span class="o">!=</span> <span class="s2">&quot;&quot;</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">optscan_patt</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
                    <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
                    <span class="n">line</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
                    <span class="n">endScan</span> <span class="o">=</span> <span class="kc">False</span>
                    <span class="k">while</span> <span class="ow">not</span> <span class="n">endScan</span><span class="p">:</span>
                        <span class="n">data</span><span class="p">[</span><span class="s2">&quot;energies&quot;</span><span class="p">]</span> <span class="o">+=</span> <span class="n">floatList</span><span class="p">(</span><span class="n">float_patt</span><span class="o">.</span><span class="n">findall</span><span class="p">(</span><span class="n">line</span><span class="p">))</span>
                        <span class="n">line</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
                        <span class="k">while</span> <span class="n">coord_patt</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
                            <span class="n">icname</span> <span class="o">=</span> <span class="n">line</span><span class="o">.</span><span class="n">split</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
                            <span class="k">if</span> <span class="n">icname</span> <span class="ow">in</span> <span class="n">data</span><span class="p">[</span><span class="s2">&quot;coords&quot;</span><span class="p">]:</span>
                                <span class="n">data</span><span class="p">[</span><span class="s2">&quot;coords&quot;</span><span class="p">][</span><span class="n">icname</span><span class="p">]</span> <span class="o">+=</span> <span class="n">floatList</span><span class="p">(</span><span class="n">float_patt</span><span class="o">.</span><span class="n">findall</span><span class="p">(</span><span class="n">line</span><span class="p">))</span>
                            <span class="k">else</span><span class="p">:</span>
                                <span class="n">data</span><span class="p">[</span><span class="s2">&quot;coords&quot;</span><span class="p">][</span><span class="n">icname</span><span class="p">]</span> <span class="o">=</span> <span class="n">floatList</span><span class="p">(</span><span class="n">float_patt</span><span class="o">.</span><span class="n">findall</span><span class="p">(</span><span class="n">line</span><span class="p">))</span>
                            <span class="n">line</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
                        <span class="k">if</span> <span class="ow">not</span> <span class="n">re</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;^\s+((\s*\d+)+)&quot;</span><span class="p">,</span> <span class="n">line</span><span class="p">):</span>
                            <span class="n">endScan</span> <span class="o">=</span> <span class="kc">True</span>
                        <span class="k">else</span><span class="p">:</span>
                            <span class="n">line</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>

                <span class="k">elif</span> <span class="n">scan_patt</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
                    <span class="n">line</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
                    <span class="n">data</span><span class="p">[</span><span class="s2">&quot;coords&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="n">icname</span><span class="p">:</span> <span class="nb">list</span><span class="p">()</span>
                                      <span class="k">for</span> <span class="n">icname</span> <span class="ow">in</span> <span class="n">line</span><span class="o">.</span><span class="n">split</span><span class="p">()[</span><span class="mi">1</span><span class="p">:</span><span class="o">-</span><span class="mi">1</span><span class="p">]}</span>
                    <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
                    <span class="n">line</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
                    <span class="k">while</span> <span class="ow">not</span> <span class="n">re</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;^\s-+&quot;</span><span class="p">,</span> <span class="n">line</span><span class="p">):</span>
                        <span class="n">values</span> <span class="o">=</span> <span class="n">floatList</span><span class="p">(</span><span class="n">line</span><span class="o">.</span><span class="n">split</span><span class="p">())</span>
                        <span class="n">data</span><span class="p">[</span><span class="s2">&quot;energies&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">values</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span>
                        <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">icname</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;coords&quot;</span><span class="p">]):</span>
                            <span class="n">data</span><span class="p">[</span><span class="s2">&quot;coords&quot;</span><span class="p">][</span><span class="n">icname</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">values</span><span class="p">[</span><span class="n">i</span><span class="o">+</span><span class="mi">1</span><span class="p">])</span>
                        <span class="n">line</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">line</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>

        <span class="k">return</span> <span class="n">data</span></div>

<div class="viewcode-block" id="GaussianOutput.get_scan_plot"><a class="viewcode-back" href="../../../pymatgen.io.gaussian.html#pymatgen.io.gaussian.GaussianOutput.get_scan_plot">[docs]</a>    <span class="k">def</span> <span class="nf">get_scan_plot</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">coords</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Get a matplotlib plot of the potential energy surface.</span>

<span class="sd">        Args:</span>
<span class="sd">            coords: internal coordinate name to use as abcissa.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="kn">from</span> <span class="nn">pymatgen.util.plotting</span> <span class="kn">import</span> <span class="n">pretty_plot</span>

        <span class="n">plt</span> <span class="o">=</span> <span class="n">pretty_plot</span><span class="p">(</span><span class="mi">12</span><span class="p">,</span> <span class="mi">8</span><span class="p">)</span>

        <span class="n">d</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">read_scan</span><span class="p">()</span>

        <span class="k">if</span> <span class="n">coords</span> <span class="ow">and</span> <span class="n">coords</span> <span class="ow">in</span> <span class="n">d</span><span class="p">[</span><span class="s2">&quot;coords&quot;</span><span class="p">]:</span>
            <span class="n">x</span> <span class="o">=</span> <span class="n">d</span><span class="p">[</span><span class="s2">&quot;coords&quot;</span><span class="p">][</span><span class="n">coords</span><span class="p">]</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">xlabel</span><span class="p">(</span><span class="n">coords</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">x</span> <span class="o">=</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">d</span><span class="p">[</span><span class="s2">&quot;energies&quot;</span><span class="p">]))</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">xlabel</span><span class="p">(</span><span class="s2">&quot;points&quot;</span><span class="p">)</span>

        <span class="n">plt</span><span class="o">.</span><span class="n">ylabel</span><span class="p">(</span><span class="s2">&quot;Energy (eV)&quot;</span><span class="p">)</span>

        <span class="n">e_min</span> <span class="o">=</span> <span class="nb">min</span><span class="p">(</span><span class="n">d</span><span class="p">[</span><span class="s2">&quot;energies&quot;</span><span class="p">])</span>
        <span class="n">y</span> <span class="o">=</span> <span class="p">[(</span><span class="n">e</span> <span class="o">-</span> <span class="n">e_min</span><span class="p">)</span> <span class="o">*</span> <span class="n">Ha_to_eV</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">d</span><span class="p">[</span><span class="s2">&quot;energies&quot;</span><span class="p">]]</span>

        <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="s2">&quot;ro--&quot;</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">plt</span></div>

<div class="viewcode-block" id="GaussianOutput.save_scan_plot"><a class="viewcode-back" href="../../../pymatgen.io.gaussian.html#pymatgen.io.gaussian.GaussianOutput.save_scan_plot">[docs]</a>    <span class="k">def</span> <span class="nf">save_scan_plot</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="o">=</span><span class="s2">&quot;scan.pdf&quot;</span><span class="p">,</span>
                       <span class="n">img_format</span><span class="o">=</span><span class="s2">&quot;pdf&quot;</span><span class="p">,</span> <span class="n">coords</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Save matplotlib plot of the potential energy surface to a file.</span>

<span class="sd">        Args:</span>
<span class="sd">            filename: Filename to write to.</span>
<span class="sd">            img_format: Image format to use. Defaults to EPS.</span>
<span class="sd">            coords: internal coordinate name to use as abcissa.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">plt</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_scan_plot</span><span class="p">(</span><span class="n">coords</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">savefig</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="nb">format</span><span class="o">=</span><span class="n">img_format</span><span class="p">)</span></div>

<div class="viewcode-block" id="GaussianOutput.read_excitation_energies"><a class="viewcode-back" href="../../../pymatgen.io.gaussian.html#pymatgen.io.gaussian.GaussianOutput.read_excitation_energies">[docs]</a>    <span class="k">def</span> <span class="nf">read_excitation_energies</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Read a excitation energies after a TD-DFT calculation.</span>

<span class="sd">        Returns:</span>

<span class="sd">            A list: A list of tuple for each transition such as</span>
<span class="sd">                    [(energie (eV), lambda (nm), oscillatory strength), ... ]</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">transitions</span> <span class="o">=</span> <span class="nb">list</span><span class="p">()</span>

        <span class="c1"># read in file</span>
        <span class="k">with</span> <span class="n">zopen</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">filename</span><span class="p">,</span> <span class="s2">&quot;r&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
            <span class="n">line</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
            <span class="n">td</span> <span class="o">=</span> <span class="kc">False</span>
            <span class="k">while</span> <span class="n">line</span> <span class="o">!=</span> <span class="s2">&quot;&quot;</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">re</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;^\sExcitation energies and oscillator strengths:&quot;</span><span class="p">,</span> <span class="n">line</span><span class="p">):</span>
                    <span class="n">td</span> <span class="o">=</span> <span class="kc">True</span>

                <span class="k">if</span> <span class="n">td</span><span class="p">:</span>
                    <span class="k">if</span> <span class="n">re</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;^\sExcited State\s*\d&quot;</span><span class="p">,</span> <span class="n">line</span><span class="p">):</span>
                        <span class="n">val</span> <span class="o">=</span> <span class="p">[</span><span class="nb">float</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">float_patt</span><span class="o">.</span><span class="n">findall</span><span class="p">(</span><span class="n">line</span><span class="p">)]</span>
                        <span class="n">transitions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">tuple</span><span class="p">(</span><span class="n">val</span><span class="p">[</span><span class="mi">0</span><span class="p">:</span><span class="mi">3</span><span class="p">]))</span>
                <span class="n">line</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">transitions</span></div>

<div class="viewcode-block" id="GaussianOutput.get_spectre_plot"><a class="viewcode-back" href="../../../pymatgen.io.gaussian.html#pymatgen.io.gaussian.GaussianOutput.get_spectre_plot">[docs]</a>    <span class="k">def</span> <span class="nf">get_spectre_plot</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sigma</span><span class="o">=</span><span class="mf">0.05</span><span class="p">,</span> <span class="n">step</span><span class="o">=</span><span class="mf">0.01</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Get a matplotlib plot of the UV-visible xas. Transition are plotted</span>
<span class="sd">        as vertical lines and as a sum of normal functions with sigma with. The</span>
<span class="sd">        broadening is applied in energy and the xas is plotted as a function</span>
<span class="sd">        of the wavelength.</span>

<span class="sd">        Args:</span>
<span class="sd">            sigma: Full width at half maximum in eV for normal functions.</span>
<span class="sd">            step: bin interval in eV</span>

<span class="sd">        Returns:</span>
<span class="sd">            A dict: {&quot;energies&quot;: values, &quot;lambda&quot;: values, &quot;xas&quot;: values}</span>
<span class="sd">                    where values are lists of abscissa (energies, lamba) and</span>
<span class="sd">                    the sum of gaussian functions (xas).</span>
<span class="sd">            A matplotlib plot.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="kn">from</span> <span class="nn">pymatgen.util.plotting</span> <span class="kn">import</span> <span class="n">pretty_plot</span>
        <span class="kn">from</span> <span class="nn">scipy.stats</span> <span class="kn">import</span> <span class="n">norm</span>
        <span class="n">plt</span> <span class="o">=</span> <span class="n">pretty_plot</span><span class="p">(</span><span class="mi">12</span><span class="p">,</span> <span class="mi">8</span><span class="p">)</span>

        <span class="n">transitions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">read_excitation_energies</span><span class="p">()</span>

        <span class="n">minval</span> <span class="o">=</span> <span class="nb">min</span><span class="p">([</span><span class="n">val</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="k">for</span> <span class="n">val</span> <span class="ow">in</span> <span class="n">transitions</span><span class="p">])</span> <span class="o">-</span> <span class="mf">5.0</span> <span class="o">*</span> <span class="n">sigma</span>
        <span class="n">maxval</span> <span class="o">=</span> <span class="nb">max</span><span class="p">([</span><span class="n">val</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="k">for</span> <span class="n">val</span> <span class="ow">in</span> <span class="n">transitions</span><span class="p">])</span> <span class="o">+</span> <span class="mf">5.0</span> <span class="o">*</span> <span class="n">sigma</span>
        <span class="n">npts</span> <span class="o">=</span> <span class="nb">int</span><span class="p">((</span><span class="n">maxval</span> <span class="o">-</span> <span class="n">minval</span><span class="p">)</span> <span class="o">/</span> <span class="n">step</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span>

        <span class="n">eneval</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">linspace</span><span class="p">(</span><span class="n">minval</span><span class="p">,</span> <span class="n">maxval</span><span class="p">,</span> <span class="n">npts</span><span class="p">)</span>  <span class="c1"># in eV</span>
        <span class="n">lambdaval</span> <span class="o">=</span> <span class="p">[</span><span class="n">cst</span><span class="o">.</span><span class="n">h</span> <span class="o">*</span> <span class="n">cst</span><span class="o">.</span><span class="n">c</span> <span class="o">/</span> <span class="p">(</span><span class="n">val</span> <span class="o">*</span> <span class="n">cst</span><span class="o">.</span><span class="n">e</span><span class="p">)</span> <span class="o">*</span> <span class="mf">1.e9</span>
                     <span class="k">for</span> <span class="n">val</span> <span class="ow">in</span> <span class="n">eneval</span><span class="p">]</span>  <span class="c1"># in nm</span>

        <span class="c1"># sum of gaussian functions</span>
        <span class="n">spectre</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">npts</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">trans</span> <span class="ow">in</span> <span class="n">transitions</span><span class="p">:</span>
            <span class="n">spectre</span> <span class="o">+=</span> <span class="n">trans</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">*</span> <span class="n">norm</span><span class="p">(</span><span class="n">eneval</span><span class="p">,</span> <span class="n">trans</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">sigma</span><span class="p">)</span>
        <span class="n">spectre</span> <span class="o">/=</span> <span class="n">spectre</span><span class="o">.</span><span class="n">max</span><span class="p">()</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">lambdaval</span><span class="p">,</span> <span class="n">spectre</span><span class="p">,</span> <span class="s2">&quot;r-&quot;</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s2">&quot;spectre&quot;</span><span class="p">)</span>

        <span class="n">data</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;energies&quot;</span><span class="p">:</span> <span class="n">eneval</span><span class="p">,</span> <span class="s2">&quot;lambda&quot;</span><span class="p">:</span> <span class="n">lambdaval</span><span class="p">,</span> <span class="s2">&quot;xas&quot;</span><span class="p">:</span> <span class="n">spectre</span><span class="p">}</span>

        <span class="c1"># plot transitions as vlines</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">vlines</span><span class="p">([</span><span class="n">val</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="k">for</span> <span class="n">val</span> <span class="ow">in</span> <span class="n">transitions</span><span class="p">],</span>
                   <span class="mf">0.</span><span class="p">,</span>
                   <span class="p">[</span><span class="n">val</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="k">for</span> <span class="n">val</span> <span class="ow">in</span> <span class="n">transitions</span><span class="p">],</span>
                   <span class="n">color</span><span class="o">=</span><span class="s2">&quot;blue&quot;</span><span class="p">,</span>
                   <span class="n">label</span><span class="o">=</span><span class="s2">&quot;transitions&quot;</span><span class="p">,</span>
                   <span class="n">linewidth</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>

        <span class="n">plt</span><span class="o">.</span><span class="n">xlabel</span><span class="p">(</span><span class="s2">&quot;$</span><span class="se">\\</span><span class="s2">lambda$ (nm)&quot;</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">ylabel</span><span class="p">(</span><span class="s2">&quot;Arbitrary unit&quot;</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">legend</span><span class="p">()</span>

        <span class="k">return</span> <span class="n">data</span><span class="p">,</span> <span class="n">plt</span></div>

<div class="viewcode-block" id="GaussianOutput.save_spectre_plot"><a class="viewcode-back" href="../../../pymatgen.io.gaussian.html#pymatgen.io.gaussian.GaussianOutput.save_spectre_plot">[docs]</a>    <span class="k">def</span> <span class="nf">save_spectre_plot</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="o">=</span><span class="s2">&quot;spectre.pdf&quot;</span><span class="p">,</span> <span class="n">img_format</span><span class="o">=</span><span class="s2">&quot;pdf&quot;</span><span class="p">,</span>
                          <span class="n">sigma</span><span class="o">=</span><span class="mf">0.05</span><span class="p">,</span> <span class="n">step</span><span class="o">=</span><span class="mf">0.01</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Save matplotlib plot of the spectre to a file.</span>

<span class="sd">        Args:</span>
<span class="sd">            filename: Filename to write to.</span>
<span class="sd">            img_format: Image format to use. Defaults to EPS.</span>
<span class="sd">            sigma: Full width at half maximum in eV for normal functions.</span>
<span class="sd">            step: bin interval in eV</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">d</span><span class="p">,</span> <span class="n">plt</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_spectre_plot</span><span class="p">(</span><span class="n">sigma</span><span class="p">,</span> <span class="n">step</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">savefig</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="nb">format</span><span class="o">=</span><span class="n">img_format</span><span class="p">)</span></div>

<div class="viewcode-block" id="GaussianOutput.to_input"><a class="viewcode-back" href="../../../pymatgen.io.gaussian.html#pymatgen.io.gaussian.GaussianOutput.to_input">[docs]</a>    <span class="k">def</span> <span class="nf">to_input</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">mol</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">charge</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                 <span class="n">spin_multiplicity</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">title</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">functional</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                 <span class="n">basis_set</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">route_parameters</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">input_parameters</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                 <span class="n">link0_parameters</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">dieze_tag</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">cart_coords</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Create a new input object using by default the last geometry read in</span>
<span class="sd">        the output file and with the same calculation parameters. Arguments</span>
<span class="sd">        are the same as GaussianInput class.</span>

<span class="sd">        Returns</span>
<span class="sd">            gaunip (GaussianInput) : the gaussian input object</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">mol</span><span class="p">:</span>
            <span class="n">mol</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">final_structure</span>

        <span class="k">if</span> <span class="n">charge</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">charge</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">charge</span>

        <span class="k">if</span> <span class="n">spin_multiplicity</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">spin_multiplicity</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">spin_multiplicity</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="n">title</span><span class="p">:</span>
            <span class="n">title</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">title</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="n">functional</span><span class="p">:</span>
            <span class="n">functional</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">functional</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="n">basis_set</span><span class="p">:</span>
            <span class="n">basis_set</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">basis_set</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="n">route_parameters</span><span class="p">:</span>
            <span class="n">route_parameters</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">route_parameters</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="n">link0_parameters</span><span class="p">:</span>
            <span class="n">link0_parameters</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">link0</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="n">dieze_tag</span><span class="p">:</span>
            <span class="n">dieze_tag</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dieze_tag</span>

        <span class="k">return</span> <span class="n">GaussianInput</span><span class="p">(</span><span class="n">mol</span><span class="o">=</span><span class="n">mol</span><span class="p">,</span>
                             <span class="n">charge</span><span class="o">=</span><span class="n">charge</span><span class="p">,</span>
                             <span class="n">spin_multiplicity</span><span class="o">=</span><span class="n">spin_multiplicity</span><span class="p">,</span>
                             <span class="n">title</span><span class="o">=</span><span class="n">title</span><span class="p">,</span>
                             <span class="n">functional</span><span class="o">=</span><span class="n">functional</span><span class="p">,</span>
                             <span class="n">basis_set</span><span class="o">=</span><span class="n">basis_set</span><span class="p">,</span>
                             <span class="n">route_parameters</span><span class="o">=</span><span class="n">route_parameters</span><span class="p">,</span>
                             <span class="n">input_parameters</span><span class="o">=</span><span class="n">input_parameters</span><span class="p">,</span>
                             <span class="n">link0_parameters</span><span class="o">=</span><span class="n">link0_parameters</span><span class="p">,</span>
                             <span class="n">dieze_tag</span><span class="o">=</span><span class="n">dieze_tag</span><span class="p">)</span></div></div>
</pre></div>

            <div class="clearer"></div>
          </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../index.html">pymatgen 2020.7.3 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../../pymatgen.html" >pymatgen</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">pymatgen.io.gaussian</a></li> 
      </ul>
    </div>

    <div class="footer" role="contentinfo">
        &#169; Copyright 2011, Pymatgen Development Team.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.1.2.
    </div>
<div class="footer">This page uses <a href="http://analytics.google.com/">
Google Analytics</a> to collect statistics. You can disable it by blocking
the JavaScript coming from www.google-analytics.com.
<script type="text/javascript">
  (function() {
    var ga = document.createElement('script');
    ga.src = ('https:' == document.location.protocol ?
              'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    ga.setAttribute('async', 'true');
    document.documentElement.firstChild.appendChild(ga);
  })();
</script>
</div>

  </body>
</html>